Data description

Data was simulated using VirtualCommunity code.
Simulated data contains 20 data sets.
Models : Po Models were fitted for 2 datasets :
1.Env5Sp - environmental filetering only for 5 species (asssuming no interactions).
2.FacDen10Sp - environmental filetering + facilitation for 10 species.

me5 <- load_object("model-2019-04-09-19-02-16.rda")
#load("model-2019-04-09-19-02-16.rda")
summary(me5)
## Summary for model '/var/folders/2z/0sxx_8ts2pxcp028sy41wfgc0000gn/T//RtmpeNqPAL/file1219c690e12c'
## Saved parameters: B Rho EnvRho Tau 
## MCMC ran in parallel for 34.541 minutes at time 2019-04-09 18:27:42.
## 
## For each of 5 chains:
## Adaptation:            250000 iterations (possibly insufficient)
## Burn-in:               0 iterations
## Thin rate:             100 iterations
## Total chain length:    270000 iterations
## Posterior sample size: 200 draws
## 
## **WARNING** Rhat values indicate convergence failure.
me5$Rhat
## $B
##          [,1]     [,2]      [,3]
## [1,] 1.135989 1.018197 1.1245544
## [2,] 1.013833 1.004344 1.0112301
## [3,] 1.002576 1.001542 0.9994323
## [4,] 1.031917 1.004833 1.0323277
## [5,] 1.018700 1.015160 1.0197400
## 
## $Rho
##           [,1]     [,2]     [,3]      [,4]     [,5]
## [1,] 0.9976643 1.039458 1.052623 1.0094656 1.015226
## [2,] 1.0394584 0.997953 1.026200 1.0177929 1.007785
## [3,] 1.0526226 1.026200 0.997928 1.0144650 1.063094
## [4,] 1.0094656 1.017793 1.014465 0.9979433 1.015443
## [5,] 1.0152264 1.007785 1.063094 1.0154435       NA
## 
## $EnvRho
##           [,1]      [,2]      [,3]      [,4]      [,5]
## [1,] 0.9976838 1.0673883 1.0948150 1.0885041 1.1003815
## [2,] 1.0673883 0.9977664 1.0114810 1.0220815 1.0142215
## [3,] 1.0948150 1.0114810 0.9982452 1.0139774 1.0122185
## [4,] 1.0885041 1.0220815 1.0139774 0.9977469 1.0163906
## [5,] 1.1003815 1.0142215 1.0122185 1.0163906 0.9980662
## 
## $Tau
##          [,1]     [,2]     [,3]     [,4]     [,5]
## [1,] 1.469444 1.020321 1.044180 1.030605 1.015437
## [2,] 1.020321 1.140789 1.011127 1.051937 1.012689
## [3,] 1.044180 1.011127 1.124484 1.011076 1.019733
## [4,] 1.030605 1.051937 1.011076 1.195892 1.012849
## [5,] 1.015437 1.012689 1.019733 1.012849 1.063968
me5$n.eff
## $B
##      [,1] [,2] [,3]
## [1,]   29  155   32
## [2,]  257  547  283
## [3,]  756 1000 1000
## [4,]  103  593   94
## [5,]  181  204  177
## 
## $Rho
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    1   86   66  284  232
## [2,]   86    1  132  204  350
## [3,]   66  132    1  195   53
## [4,]  284  204  195    1  195
## [5,]  232  350   53  195    1
## 
## $EnvRho
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    1   54   39   53   48
## [2,]   54    1  231  129  277
## [3,]   39  231    1  189  273
## [4,]   53  129  189    1  181
## [5,]   48  277  273  181    1
## 
## $Tau
##      [,1] [,2] [,3] [,4] [,5]
## [1,]   12  167  129  116  376
## [2,]  167   29  411   82  216
## [3,]  129  411   33  491  159
## [4,]  116   82  491   21  251
## [5,]  376  216  159  251   59
me5$mcmc.info[1:7]
## $n.chains
## [1] 5
## 
## $n.adapt
## [1] 250000 250000 250000 250000 250000
## 
## $sufficient.adapt
## [1] FALSE FALSE FALSE FALSE FALSE
## 
## $n.iter
## [1] 20000
## 
## $n.burnin
## [1] 0
## 
## $n.thin
## [1] 100
## 
## $n.samples
## [1] 1000

Environment filtering 5 species

JSDM

Model for \(\textbf{EnvEvenSp5}\)

data<-sim_data$EnvEvenSp5
data <- list(
  Y = subset(data, select = -env),
  X = cbind(1, scale(poly(data$env, 2))),
  covx = cov(cbind(1, scale(poly(data$env, 2)))),
  K = 3,
  J = ncol(data) - 1,
  n = nrow(data),
  I = diag(ncol(data) - 1),
  df = ncol(data)
)

Y_cor<-cor(data$Y)

to_prec<-function(m){
  n<-dim(m)[1]
  Tau_n<-matrix(nrow=n, ncol=n)
  for (j in 1:n) {
   for (k in 1:n){
    Tau_n[j, k] <-  -m[j, k]/sqrt((m[j,j]*m[k,k]))
   }
  }
  return(Tau_n)
}

#Tau_n<-matrix(nrow=dim(model$mean$Tau)[1], ncol=dim(model$mean$Tau)[1])
Tau_n<-to_prec(me5$mean$Tau)
#Tau_k<-Tau_n*(!(model$q97.5$Tau>0 & model$q2.5$Tau<0))

par(mfrow=c(2,4),oma = c(3, 1, 2, 1))
corrplot(Y_cor, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
title("Correlation cor(Y)")
corrplot(me5$mean$EnvRho, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
title("EnvRho")
corrplot(me5$mean$EnvRho*(!me5$overlap0$EnvRho), diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
title("EnvRho signif")
corrplot(me5$mean$Rho, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
title("Rho")
corrplot(me5$mean$Rho*(!me5$overlap0$Rho), diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
title("Rho signif")
corrplot(Tau_n, diag = FALSE, order ="original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
title("Tau")
corrplot(Tau_n*(!me5$overlap0$Tau), diag = FALSE, order ="original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
title("Tau")

GJAM

############################################################Functions
makeSymm <- function(m) {
  m[upper.tri(m)] <- t(m)[upper.tri(m)]
  return(m)
}


convert_to_m<-function(ar){
  d <-floor((sqrt(length(ar)*8+1)-1)/2)
  C <- matrix(0,d,d)
  i.lwr <- which(lower.tri(C, diag = TRUE), arr.ind=TRUE)
  C[i.lwr] <- ar
  C<-makeSymm(C)
  return(t(C))
}

fit_gjam<-function(data, it=2500,burn=500 , name="./gjam_models/temp.rda",interact=diag(ncol(data$Y))){
  #setup parameters
  data <- list(
    Y = subset(data, select = -env),
    X = cbind(1, scale(poly(data$env, 2))),
    covx = cov(cbind(1, scale(poly(data$env, 2)))),
    K = 3,
    J = ncol(data) - 1,
    n = nrow(data),
    I = diag(ncol(data) - 1),
    df = ncol(data)
  )
  xdata<-as.data.frame(data$X[,-1])
  colnames(xdata)<- c("env","env2")
  ydata<-as.data.frame(data$Y)
  ###formula
  formula<-as.formula( ~env+ env2)
  ml   <- list(ng = it, burnin = burn, typeNames = 'PA')
  ####fit
  
  
  mod_gjam1  <- gjam(formula, xdata = xdata, ydata = ydata, modelList = ml)
  save(mod_gjam1, file = name)
  summary(mod_gjam1)
  
  Tau <- solve(mod_gjam1$parameters$sigMu)
  Tau_n = to_prec(Tau)
  
  postH<-apply(mod_gjam1$chains$sgibbs, 2, quantile,0.95)
  postL<-apply(mod_gjam1$chains$sgibbs, 2, quantile,0.05)
  
  
  pH<-convert_to_m(postH)
  pL<-convert_to_m(postL)
  
  R_sign<-cov2cor(mod_gjam1$parameters$sigMu)*(!(pH>0 & pL<0))
  
  par(mfrow=c(2,3),oma = c(1, 1, 1, 1))
  corrplot(cor(ydata), diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("Correlation cor(Y)")
  corrplot(mod_gjam1$parameters$corMu, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("R")
  corrplot(mod_gjam1$parameters$ematrix, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("E matrix")
  corrplot(Tau_n, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("Tau")
  corrplot(R_sign, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("R signif")
  corrplot(interact, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("True interactions")
}

load_gjam<-function(data,name="./gjam_models/temp.rda",interact=diag(ncol(data$Y))){
  #setup parameters
  data <- list(
    Y = subset(data, select = -env),
    X = cbind(1, scale(poly(data$env, 2))),
    covx = cov(cbind(1, scale(poly(data$env, 2)))),
    K = 3,
    J = ncol(data) - 1,
    n = nrow(data),
    I = diag(ncol(data) - 1),
    df = ncol(data)
  )

  
  gj_mod<-load_object(name)
  summary(gj_mod)
  
  Tau <- solve(gj_mod$parameters$sigMu)
  Tau_n = to_prec(Tau)
  postH<-apply(gj_mod$chains$sgibbs, 2, quantile,0.95)
  postL<-apply(gj_mod$chains$sgibbs, 2, quantile,0.05)
  pH<-convert_to_m(postH)
  pL<-convert_to_m(postL)
  R_sign<-cov2cor(gj_mod$parameters$sigMu)*(!(pH>0 & pL<0))

  par(mfrow=c(2,3),oma = c(1, 1, 1, 1))
  corrplot(cor(data$Y), diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("Correlation cor(Y)")
  corrplot(gj_mod$parameters$corMu, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("R")
  corrplot(gj_mod$parameters$ematrix, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("E matrix")
  corrplot(Tau_n, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("Tau")
  corrplot(R_sign, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("R signif")
  corrplot(interact, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("True interactions")
}

######################################################################

data<-sim_data$EnvEvenSp5

#fit_gjam(data,2000,1000,"./gjam_models/gjam5env.rda")
load_gjam(data,name="./gjam_models/gjam5env.rda")
## 
## Sensitivity by predictor variables f:
##      Estimate   SE CI_025 CI_975
## env       9.5 3.13   5.08   16.4
## env2     31.9 7.93  20.50   50.6
## 
## Coefficient matrix B:
##              sp01   sp02    sp03   sp04   sp05
## intercept -0.0312  0.646  1.2500  0.704 -1.200
## env       -2.4200 -1.800  0.0438  1.710  2.870
## env2       0.9440 -0.527 -0.9410 -0.598 -0.665
## RMSPE      0.2780  0.327  0.3760  0.309  0.327
## 
## Coefficient matrix B:
##                Estimate     SE  CI_025 CI_975 sig95
## sp01_intercept  -0.0312 0.0775 -0.1940  0.107      
## sp01_env        -2.4200 0.1170 -2.6500 -2.200     *
## sp01_env2        0.9440 0.0938  0.7780  1.130     *
## sp02_intercept   0.6460 0.0651  0.5220  0.771     *
## sp02_env        -1.8000 0.0911 -1.9900 -1.630     *
## sp02_env2       -0.5270 0.0741 -0.6700 -0.389     *
## sp03_intercept   1.2500 0.0672  1.1100  1.380     *
## sp03_env         0.0438 0.0465 -0.0447  0.132      
## sp03_env2       -0.9410 0.0764 -1.0900 -0.781     *
## sp04_intercept   0.7040 0.0865  0.5590  0.881     *
## sp04_env         1.7100 0.0897  1.5500  1.890     *
## sp04_env2       -0.5980 0.0608 -0.7170 -0.486     *
## sp05_intercept  -1.2000 0.0953 -1.3700 -1.000     *
## sp05_env         2.8700 0.1380  2.6300  3.170     *
## sp05_env2       -0.6650 0.0610 -0.7840 -0.545     *
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
## Coefficient matrix B, standardized for X:
## NULL
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
## Coefficient matrix B, standardized for X and W:
## NULL
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
##  Design Table
##      env env2
## VIF    1    1
## env2   0   NA
## 
##  Sample contains n = 500 observations on S = 5 response variables, and 2 predictors.  Data types (typeNames) include PA. There are 0 missing values in X and 0 missing values in Y. The RMSPE is 0.325, and the DIC is 25294.  Computation involved 2000 Gibbs steps, with a burnin of 1000.

HMSC

#setwd("~/Tesi/Code/Ecology-models-master/simcoms-master/ExampleFiles")
fit_hmsc<-function(data,label="F_t",nsamples = 1000,nchains=2,name="./HMmodels/hmtemp.rda" ){
  if (label=="F_t"){
    Y_data = subset(data, select = -env)
    ns<- ncol(Y_data)
    np <- nrow(Y_data)
    X<-scale(poly(data$env[1:np], 2))
    colnames(X)<-c("env","env2")
    studyDesign = data.frame(sample = as.factor(1:np))
    rL = HmscRandomLevel(units = studyDesign$sample)
    m = Hmsc(Y=as.matrix(Y_data), XData=as.data.frame(X), XFormula=~env+env2, distr="probit",
             studyDesign = studyDesign, ranLevels = list(sample = rL))
    m = sampleMcmc(m, nsamples, thin=10, adaptNf=c(200,200), transient=500,nChains=nchains ,verbose=F)
    save(m, file = name)
    return(m)
  }
  if (label=="L_d"){
    return(load_object(name))
  }
}

data<-sim_data$EnvEvenSp5
hm_mod<-fit_hmsc(data,"F_t",name="./HMmodels/hm5env.rda" )
#hm_mod<-load_object("./HMmodels/hm5env.rda")

Convergence:

hm_conv<-function(mod){
  codaList = convertToCodaObject(mod)

  #convergence histograms
  hist(effectiveSize(codaList$Beta), main="ess(beta)")
  hist(gelman.diag(codaList$Beta,multivariate=FALSE)$psrf, main="psrf(beta)")
  
  hist(effectiveSize(codaList$Omega[[1]]), main="ess(omega)")
  hist(gelman.diag(codaList$Omega[[1]], multivariate=FALSE)$psrf, main="psrf(omega)")
}

hm_conv(hm_mod)

Study of interactions

hm_inter<-function(mod, nchains=2,nsamples = 1000, interact=diag(ns)){
  getOmega = function(a,r=1)
  return(crossprod(a$Lambda[[r]]))
  ns<-mod$ns
  postOmega1 = array(unlist(lapply(mod$postList[[1]],getOmega)),c(ns,ns,mod$samples))
  postOmega2 = array(unlist(lapply(mod$postList[[2]],getOmega)),c(ns,ns,mod$samples))
  
  postOmega<-abind(postOmega1,postOmega2,along=3)
  postOmegaMean = apply(postOmega,c(1,2),mean)
  postOmegaUp=apply(postOmega,c(1,2),quantile,0.95)
  postOmegaLo=apply(postOmega,c(1,2),quantile,0.05)
  
  postR<-array(dim=c(ns,ns,nchains*nsamples))
  for(i in 1:dim(postOmega)[3])
  postR[,,i]<-stats::cov2cor(postOmega[,,i])
  
  
  postRMean = apply(postR,c(1,2),mean)
  postRUp=apply(postR,c(1,2),quantile,0.95)
  postRLo=apply(postR,c(1,2),quantile,0.05)
  
  Tau = solve(postOmegaMean)
  Tau_n = cov2cor(Tau)
  
  
  Toplot_R<-postRMean*(!(postRUp>0 & postRLo<0))
  
  # Omegacor<- computeAssociations(m)
  # supportLevel<- 0.95
  # toPlot<- ((Omegacor[[1]]$support>supportLevel)+ (Omegacor[[1]]$support<(1-supportLevel))>0)*Omegacor[[1]]$mean
  # corrplot(toPlot, method="color", col=colorRampPalette(c("blue", "white", "red"))(200))
  
  par(mfrow=c(2,3),oma = c(1, 1, 1, 1))
  corrplot(cor(hm_mod$Y), diag = FALSE, order = "FPC",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("Correlation cor(Y)")
  corrplot(postRMean, diag = FALSE, order = "FPC",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("R")
  corrplot(Toplot_R, diag = FALSE, order = "FPC",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("Plot only non zero value")
  corrplot(Tau_n, diag = FALSE, order = "FPC",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("Partial correlation matrix")
  corrplot(interact, diag = FALSE, order = "FPC",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("True interactions")
}


hm_inter(hm_mod)

Environmental filtering 10 species

JSDM

me10 <- load_object("model-2019-04-10-08-26-20.rda")
#load("model-2019-04-09-19-02-16.rda")
summary(me10)
## Summary for model '/tmp/RtmpKix4lZ/file40e957831178'
## Saved parameters: B Rho EnvRho 
## MCMC ran in parallel for 683.734 minutes at time 2019-04-09 21:02:35.
## 
## For each of 5 chains:
## Adaptation:            250000 iterations (possibly insufficient)
## Burn-in:               0 iterations
## Thin rate:             100 iterations
## Total chain length:    270000 iterations
## Posterior sample size: 200 draws
## 
## **WARNING** Rhat values indicate convergence failure.
me10$Rhat
## $B
##           [,1]     [,2]     [,3]
##  [1,] 1.120326 1.068731 1.105596
##  [2,] 1.120646 1.023810 1.117608
##  [3,] 1.025126 1.021987 1.039450
##  [4,] 1.009218 1.002054 1.003472
##  [5,] 1.001461 1.003377 1.000483
##  [6,] 1.002240 1.004165 1.001141
##  [7,] 1.002028 1.005003 1.010800
##  [8,] 1.068841 1.052336 1.061238
##  [9,] 1.076116 1.070068 1.072570
## [10,] 1.453481 1.076523 1.560232
## 
## $Rho
##            [,1]      [,2]      [,3]      [,4]      [,5]     [,6]      [,7]
##  [1,] 0.9978526 1.0290591 1.0678412 1.0599436 1.0399056 1.028928 1.0507803
##  [2,] 1.0290591 0.9982297 1.0197007 1.0252205 1.0401715 1.021111 1.0172827
##  [3,] 1.0678412 1.0197007 0.9987326 1.0059132 1.0715726 1.114560 1.0315975
##  [4,] 1.0599436 1.0252205 1.0059132 0.9992124 1.0086992 1.040600 1.0561948
##  [5,] 1.0399056 1.0401715 1.0715726 1.0086992 0.9986616 1.011374 1.0423583
##  [6,] 1.0289278 1.0211114 1.1145598 1.0405996 1.0113744 0.999231 1.0127345
##  [7,] 1.0507803 1.0172827 1.0315975 1.0561948 1.0423583 1.012734 0.9988621
##  [8,] 1.0037681 1.0121168 1.0453821 1.0539626 1.0384907 1.010776 1.0065758
##  [9,] 1.0253918 1.0149548 1.0102800 1.1800843 1.0542274 1.023794 1.0145598
## [10,] 1.0160857 1.0121523 1.0122942 1.0110807 1.0574194 1.041111 1.1259440
##            [,8]     [,9]    [,10]
##  [1,] 1.0037681 1.025392 1.016086
##  [2,] 1.0121168 1.014955 1.012152
##  [3,] 1.0453821 1.010280 1.012294
##  [4,] 1.0539626 1.180084 1.011081
##  [5,] 1.0384907 1.054227 1.057419
##  [6,] 1.0107757 1.023794 1.041111
##  [7,] 1.0065758 1.014560 1.125944
##  [8,] 0.9984035 1.097070 1.049173
##  [9,] 1.0970703 1.000262 1.021051
## [10,] 1.0491732 1.021051       NA
## 
## $EnvRho
##            [,1]      [,2]      [,3]      [,4]      [,5]      [,6]
##  [1,] 0.9989701 1.0915613 1.0494713 1.0476542 1.0612422 1.0933407
##  [2,] 1.0915613 0.9980448 1.1008798 1.0605411 1.0774669 1.0677039
##  [3,] 1.0494713 1.1008798 0.9977531 1.0270558 1.0223152 1.0271401
##  [4,] 1.0476542 1.0605411 1.0270558 0.9985439 1.0055161 1.0087761
##  [5,] 1.0612422 1.0774669 1.0223152 1.0055161 0.9980406 1.0033713
##  [6,] 1.0933407 1.0677039 1.0271401 1.0087761 1.0033713 0.9976375
##  [7,] 1.1032291 1.0851283 1.0274782 1.0126996 0.9996139 1.0027872
##  [8,] 1.1457862 1.0409139 1.0640407 1.0501193 1.0278626 1.0321936
##  [9,] 1.0633837 1.0215345 1.0115341 1.0424066 1.0311304 1.0386605
## [10,] 1.2623168 1.7953449 1.1707963 1.3153329 1.2841446 1.3435169
##            [,7]      [,8]      [,9]     [,10]
##  [1,] 1.1032291 1.1457862 1.0633837 1.2623168
##  [2,] 1.0851283 1.0409139 1.0215345 1.7953449
##  [3,] 1.0274782 1.0640407 1.0115341 1.1707963
##  [4,] 1.0126996 1.0501193 1.0424066 1.3153329
##  [5,] 0.9996139 1.0278626 1.0311304 1.2841446
##  [6,] 1.0027872 1.0321936 1.0386605 1.3435169
##  [7,] 0.9983449 1.0312640 1.0319857 1.3542085
##  [8,] 1.0312640 0.9994923 1.1180936 1.2880511
##  [9,] 1.0319857 1.1180936 0.9980654 1.1956412
## [10,] 1.3542085 1.2880511 1.1956412 0.9976116
me10$n.eff
## $B
##       [,1] [,2] [,3]
##  [1,]   34   51   38
##  [2,]   33  121   31
##  [3,]  130  137   82
##  [4,]  271 1000  645
##  [5,]  824  593 1000
##  [6,]  756  670 1000
##  [7,]  729  670  259
##  [8,]   58   69   61
##  [9,]   45   47   47
## [10,]   11   47   10
## 
## $Rho
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
##  [1,]    1  119   49   54   84  102   66  519  121   186
##  [2,]  119    1  162  121   81  136  184  283  224   219
##  [3,]   49  162    1  755   53   34  120   72  256   217
##  [4,]   54  121  755    1  357   80   82   75   22   273
##  [5,]   84   81   53  357    1  269   76   84   62    59
##  [6,]  102  136   34   80  269    1  249  404  136    78
##  [7,]   66  184  120   82   76  249    1  391  363    30
##  [8,]  519  283   72   75   84  404  391    1   36    66
##  [9,]  121  224  256   22   62  136  363   36    1   157
## [10,]  186  219  217  273   59   78   30   66  157     1
## 
## $EnvRho
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
##  [1,]    1   60   74   80   59   39   39   34   89    18
##  [2,]   60    1   36   56   44   49   39   86  230     9
##  [3,]   74   36    1  144  134  112  110   51  249    23
##  [4,]   80   56  144    1  505  379  214   67   74    14
##  [5,]   59   44  134  505    1  632 1000  113  106    16
##  [6,]   39   49  112  379  632    1  801  103   86    14
##  [7,]   39   39  110  214 1000  801    1  128  102    14
##  [8,]   34   86   51   67  113  103  128    1   42    17
##  [9,]   89  230  249   74  106   86  102   42    1    23
## [10,]   18    9   23   14   16   14   14   17   23     1
me10$mcmc.info[1:7]
## $n.chains
## [1] 5
## 
## $n.adapt
## [1] 250000 250000 250000 250000 250000
## 
## $sufficient.adapt
## [1] FALSE FALSE FALSE FALSE FALSE
## 
## $n.iter
## [1] 20000
## 
## $n.burnin
## [1] 0
## 
## $n.thin
## [1] 100
## 
## $n.samples
## [1] 1000
models<-list(EnvEvenSp10=me10)
mean_correlations<-mean_cor(models)
x <- subset(mean_correlations, type != "Environmental\nFiltering Only")
acc <- by(x, x$model, function(x) sum(x$status == "TP" | x$status == "TN") / nrow(x))

#' Plot correlation parameter means
#+ plot-correlations
ggplot(mean_correlations) +
  aes(factor(nsp), rho, fill = interaction) +
  geom_hline(yintercept = 0) +
  geom_boxplot(
    outlier.size = .2, size = .1, position = position_dodge(preserve = "single")
  ) +
  scale_fill_manual(values = c("grey", "blue", "red")) +
  facet_grid(type ~ rho_type + density, switch = "y") +
  xlab("Number of species") +
  ylab("Correlation") +
  theme_bw() +
  theme(legend.position = "top")

data<-sim_data$EnvEvenSp10
data <- list(
  Y = subset(data, select = -env),
  X = cbind(1, scale(poly(data$env, 2))),
  covx = cov(cbind(1, scale(poly(data$env, 2)))),
  K = 3,
  J = ncol(data) - 1,
  n = nrow(data),
  I = diag(ncol(data) - 1),
  df = ncol(data)
)

##########################################################################################
#Tau<-solve
#Tau_n<-to_prec(me10$mean$Tau)
#Tau_k<-Tau_n*(!(model$q97.5$Tau>0 & model$q2.5$Tau<0))

plot_cor_jsdm<-function(mod,y,interact=diag(ncol(y))){
  par(mfrow=c(2,4),oma = c(3, 1, 2, 1))
  corrplot(cor(y), diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("Correlation cor(Y)")
  corrplot(mod$mean$EnvRho, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("EnvRho")
  corrplot(mod$mean$EnvRho*(!mod$overlap0$EnvRho), diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("EnvRho signif")
  corrplot(mod$mean$Rho, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("Rho")
  corrplot(mod$mean$Rho*(!mod$overlap0$Rho), diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("Rho signif")
  corrplot(interact, diag = FALSE, order = "original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  title("True interactions")
  #corrplot(Tau_n, diag = FALSE, order ="original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  #title("Tau")
  #corrplot(Tau_n*(!me10$overlap0$Tau), diag = FALSE, order ="original",tl.pos = "ld", tl.cex = 0.5, method = "color", type = "lower")
  #title("Tau")
}

plot_cor_jsdm(me10,data$Y)

Gjam

data<-sim_data$EnvEvenSp10

#fit_gjam(data,5000,500,"./gjam_models/gjam10env.rda")
load_gjam(data,name="./gjam_models/gjam10env.rda")
## 
## Sensitivity by predictor variables f:
##      Estimate   SE CI_025 CI_975
## env     233.0 58.0    120  354.0
## env2     56.7 11.8     37   82.9
## 
## Coefficient matrix B:
##              sp01    sp02   sp03   sp04   sp05   sp06   sp07   sp08  sp09
## intercept -0.2060  0.3800  1.310  0.889  1.020  0.742  0.638  0.140 0.332
## env       -2.0500 -2.5700 -2.300 -1.030 -0.189  0.542  1.090  1.740 2.520
## env2       0.0656 -0.0531  0.338 -0.533 -0.805 -0.838 -0.690 -0.425 0.640
## RMSPE      0.3300  0.2980  0.317  0.371  0.414  0.421  0.374  0.345 0.298
##             sp10
## intercept -0.577
## env        2.370
## env2       0.677
## RMSPE      0.276
## 
## Coefficient matrix B:
##                Estimate     SE   CI_025  CI_975 sig95
## sp01_intercept  -0.2060 0.0670 -0.33700 -0.0733     *
## sp01_env        -2.0500 0.1190 -2.29000 -1.8300     *
## sp01_env2        0.0656 0.0992 -0.14100  0.2380      
## sp02_intercept   0.3800 0.1030  0.18000  0.5510     *
## sp02_env        -2.5700 0.1370 -2.83000 -2.2900     *
## sp02_env2       -0.0531 0.0790 -0.19700  0.1120      
## sp03_intercept   1.3100 0.0829  1.15000  1.4700     *
## sp03_env        -2.3000 0.1260 -2.55000 -2.0600     *
## sp03_env2        0.3380 0.0712  0.20500  0.4860     *
## sp04_intercept   0.8890 0.0585  0.77400  1.0000     *
## sp04_env        -1.0300 0.0659 -1.16000 -0.9070     *
## sp04_env2       -0.5330 0.0580 -0.64200 -0.4160     *
## sp05_intercept   1.0200 0.0621  0.90800  1.1500     *
## sp05_env        -0.1890 0.0488 -0.28500 -0.0949     *
## sp05_env2       -0.8050 0.0759 -0.96000 -0.6590     *
## sp06_intercept   0.7420 0.0635  0.61600  0.8650     *
## sp06_env         0.5420 0.0558  0.43200  0.6460     *
## sp06_env2       -0.8380 0.0634 -0.96100 -0.7130     *
## sp07_intercept   0.6380 0.0795  0.50600  0.8160     *
## sp07_env         1.0900 0.0805  0.93900  1.2500     *
## sp07_env2       -0.6900 0.0595 -0.80300 -0.5700     *
## sp08_intercept   0.1400 0.0759  0.00798  0.2950     *
## sp08_env         1.7400 0.1240  1.48000  1.9600     *
## sp08_env2       -0.4250 0.1000 -0.65400 -0.2750     *
## sp09_intercept   0.3320 0.0539  0.22600  0.4370     *
## sp09_env         2.5200 0.1660  2.22000  2.8500     *
## sp09_env2        0.6400 0.0700  0.50400  0.7780     *
## sp10_intercept  -0.5770 0.0696 -0.70200 -0.4380     *
## sp10_env         2.3700 0.1130  2.16000  2.6000     *
## sp10_env2        0.6770 0.0820  0.49900  0.8200     *
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
## Coefficient matrix B, standardized for X:
## NULL
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
## Coefficient matrix B, standardized for X and W:
## NULL
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
##  Design Table
##      env env2
## VIF    1    1
## env2   0   NA
## 
##  Sample contains n = 500 observations on S = 10 response variables, and 2 predictors.  Data types (typeNames) include PA. There are 0 missing values in X and 0 missing values in Y. The RMSPE is 0.348, and the DIC is 114934.  Computation involved 5000 Gibbs steps, with a burnin of 500.

#gje10<-load_object("./gjam_models/gjam10env.rda")

#to check posterior density of s in Sigma 
#gje10<-load_object("./gjam_models/gjam10env.rda")
#plot(density(gje10$chains$sgibbs[,4]))

HMSC

data<-sim_data$EnvEvenSp10
#hm_mod<-fit_hmsc(data,"F_t",name="./HMmodels/hm10env.rda" )
hm_mod<-fit_hmsc(data,"L_d",name="./HMmodels/hm10env.rda" )

hm_conv(hm_mod)

hm_inter(hm_mod)

Environmental filtering 20 species

JSDM

me20 <- load_object("model-2019-04-11-19-06-02.rda")
#load("model-2019-04-09-19-02-16.rda")
summary(me20)
## Summary for model '/tmp/RtmpKix4lZ/file40e966e51ba7'
## Saved parameters: B Rho EnvRho 
## MCMC ran in parallel for 2079.661 minutes at time 2019-04-10 08:26:21.
## 
## For each of 5 chains:
## Adaptation:            250000 iterations (possibly insufficient)
## Burn-in:               0 iterations
## Thin rate:             100 iterations
## Total chain length:    270000 iterations
## Posterior sample size: 200 draws
## 
## **WARNING** Rhat values indicate convergence failure.
me20$Rhat
## $B
##            [,1]     [,2]      [,3]
##  [1,] 1.0442706 1.029720 1.0361972
##  [2,] 1.0952877 1.034897 1.1269662
##  [3,] 1.1802136 1.032501 1.1923295
##  [4,] 1.1676379 1.127438 1.1730872
##  [5,] 1.1455795 1.072972 1.1271668
##  [6,] 1.0378201 1.020059 1.0403266
##  [7,] 1.0966605 1.108003 1.0904722
##  [8,] 1.0030607 1.014022 1.0370032
##  [9,] 0.9987167 1.009828 0.9990432
## [10,] 1.0037613 1.001993 1.0118251
## [11,] 1.0026689 1.008913 1.0000461
## [12,] 1.0159976 1.006302 1.0073405
## [13,] 1.0051811 1.006104 1.0080195
## [14,] 1.0074564 1.025066 1.0196677
## [15,] 1.0795886 1.092827 1.0576292
## [16,] 1.0640851 1.030574 1.0506423
## [17,] 1.1797437 1.075497 1.1578266
## [18,] 1.0886486 1.061220 1.1351973
## [19,] 1.2173736 1.047060 1.1899919
## [20,] 1.1109659 1.027156 1.1309502
## 
## $Rho
##            [,1]      [,2]      [,3]      [,4]      [,5]      [,6]
##  [1,] 0.9998231 1.0160280 1.0305822 1.0279291 1.0473367 1.0780718
##  [2,] 1.0160280 0.9978814 1.0431386 1.0161541 1.0302730 1.2494328
##  [3,] 1.0305822 1.0431386 0.9995131 1.0424140 1.0801828 1.1332232
##  [4,] 1.0279291 1.0161541 1.0424140 0.9978649 1.0078637 1.0195954
##  [5,] 1.0473367 1.0302730 1.0801828 1.0078637 0.9978405 1.0057194
##  [6,] 1.0780718 1.2494328 1.1332232 1.0195954 1.0057194 0.9989582
##  [7,] 1.0447842 1.0187091 1.2106201 1.0122538 1.0231265 1.0024899
##  [8,] 1.0352789 1.0199386 1.0543410 1.0274196 1.0308456 1.0430306
##  [9,] 1.0263952 1.0567748 1.0251599 1.0435112 1.0180063 1.0212570
## [10,] 1.1596349 1.0866691 1.0261957 1.0859807 1.0081510 1.0330128
## [11,] 1.0688870 1.0270544 1.0385418 1.0576555 1.0163509 1.0028639
## [12,] 1.0546815 1.0472973 1.0351153 1.0525365 1.0666341 1.0429530
## [13,] 1.0172979 1.0987287 1.0507849 1.1504208 1.0817905 1.0506452
## [14,] 1.0133158 1.0301913 1.1696609 1.0086273 1.0863943 1.0113239
## [15,] 1.0278406 1.0242104 1.0577668 1.0085084 1.0621628 1.1185167
## [16,] 1.0427642 1.0231871 1.0566623 1.0653141 1.0452490 1.0761694
## [17,] 1.0321550 1.0370350 1.0481609 1.0622793 1.0465552 1.0191210
## [18,] 1.0118686 1.0108567 1.0583566 1.0487757 1.0125671 1.0215094
## [19,] 1.0504864 1.0127250 1.0239930 1.0279518 1.0246607 1.0263601
## [20,] 1.0227614 1.0091419 1.0259128 1.0057442 1.0018726 1.0152869
##            [,7]      [,8]      [,9]     [,10]     [,11]     [,12]
##  [1,] 1.0447842 1.0352789 1.0263952 1.1596349 1.0688870 1.0546815
##  [2,] 1.0187091 1.0199386 1.0567748 1.0866691 1.0270544 1.0472973
##  [3,] 1.2106201 1.0543410 1.0251599 1.0261957 1.0385418 1.0351153
##  [4,] 1.0122538 1.0274196 1.0435112 1.0859807 1.0576555 1.0525365
##  [5,] 1.0231265 1.0308456 1.0180063 1.0081510 1.0163509 1.0666341
##  [6,] 1.0024899 1.0430306 1.0212570 1.0330128 1.0028639 1.0429530
##  [7,] 0.9978295 1.0210246 1.0209097 1.0095723 1.0332082 1.0431261
##  [8,] 1.0210246 0.9997523 1.0313886 1.0072462 1.0174961 1.0266471
##  [9,] 1.0209097 1.0313886 0.9979056 1.0022275 1.0222953 1.0217759
## [10,] 1.0095723 1.0072462 1.0022275 0.9990841 1.0279547 1.0478724
## [11,] 1.0332082 1.0174961 1.0222953 1.0279547 0.9982616 1.0053502
## [12,] 1.0431261 1.0266471 1.0217759 1.0478724 1.0053502 0.9985451
## [13,] 1.0303016 1.0278093 1.0366570 1.0700180 1.0110195 1.0256484
## [14,] 1.1458656 1.0104807 1.0159249 1.0250766 1.0239484 1.0212415
## [15,] 1.1488222 1.0219934 1.0911735 1.0736116 1.0029024 1.0495264
## [16,] 1.0122125 1.0413815 1.0869929 1.0326952 1.0188790 1.0054973
## [17,] 1.0771514 1.0410685 1.0814933 1.0908196 1.0564717 1.0392236
## [18,] 1.0292276 1.0235426 1.0642610 1.0188853 1.0288882 1.0457003
## [19,] 1.0193236 1.0389791 1.0657548 1.1371595 1.0454457 1.0994502
## [20,] 1.0036981 1.0401853 1.0189975 1.0438252 1.0143399 1.0064904
##           [,13]     [,14]     [,15]     [,16]     [,17]     [,18]
##  [1,] 1.0172979 1.0133158 1.0278406 1.0427642 1.0321550 1.0118686
##  [2,] 1.0987287 1.0301913 1.0242104 1.0231871 1.0370350 1.0108567
##  [3,] 1.0507849 1.1696609 1.0577668 1.0566623 1.0481609 1.0583566
##  [4,] 1.1504208 1.0086273 1.0085084 1.0653141 1.0622793 1.0487757
##  [5,] 1.0817905 1.0863943 1.0621628 1.0452490 1.0465552 1.0125671
##  [6,] 1.0506452 1.0113239 1.1185167 1.0761694 1.0191210 1.0215094
##  [7,] 1.0303016 1.1458656 1.1488222 1.0122125 1.0771514 1.0292276
##  [8,] 1.0278093 1.0104807 1.0219934 1.0413815 1.0410685 1.0235426
##  [9,] 1.0366570 1.0159249 1.0911735 1.0869929 1.0814933 1.0642610
## [10,] 1.0700180 1.0250766 1.0736116 1.0326952 1.0908196 1.0188853
## [11,] 1.0110195 1.0239484 1.0029024 1.0188790 1.0564717 1.0288882
## [12,] 1.0256484 1.0212415 1.0495264 1.0054973 1.0392236 1.0457003
## [13,] 0.9993036 1.0111998 1.0452570 1.0682243 1.1214569 1.1224935
## [14,] 1.0111998 0.9991569 1.0359574 1.0164046 1.0636890 1.0485195
## [15,] 1.0452570 1.0359574 0.9980932 1.0135542 1.0101433 1.0587125
## [16,] 1.0682243 1.0164046 1.0135542 0.9988827 1.0246203 1.0452053
## [17,] 1.1214569 1.0636890 1.0101433 1.0246203 0.9979598 1.0135007
## [18,] 1.1224935 1.0485195 1.0587125 1.0452053 1.0135007 0.9985193
## [19,] 1.1193621 1.0655888 1.0192911 1.0121892 1.0255944 1.0268571
## [20,] 1.0622450 1.0391188 1.0586143 1.0315405 1.0209481 1.0257643
##           [,19]    [,20]
##  [1,] 1.0504864 1.022761
##  [2,] 1.0127250 1.009142
##  [3,] 1.0239930 1.025913
##  [4,] 1.0279518 1.005744
##  [5,] 1.0246607 1.001873
##  [6,] 1.0263601 1.015287
##  [7,] 1.0193236 1.003698
##  [8,] 1.0389791 1.040185
##  [9,] 1.0657548 1.018997
## [10,] 1.1371595 1.043825
## [11,] 1.0454457 1.014340
## [12,] 1.0994502 1.006490
## [13,] 1.1193621 1.062245
## [14,] 1.0655888 1.039119
## [15,] 1.0192911 1.058614
## [16,] 1.0121892 1.031541
## [17,] 1.0255944 1.020948
## [18,] 1.0268571 1.025764
## [19,] 0.9978034 1.021101
## [20,] 1.0211006       NA
## 
## $EnvRho
##           [,1]      [,2]      [,3]     [,4]      [,5]      [,6]     [,7]
##  [1,] 0.997827 1.0441010 1.1493392 1.067035 1.1222785 1.0182787 1.052375
##  [2,] 1.044101 0.9982144 1.0871296 1.069432 1.1055942 1.1221119 1.144165
##  [3,] 1.149339 1.0871296 0.9976512 1.069019 1.1095193 1.1385559 1.088030
##  [4,] 1.067035 1.0694324 1.0690189 0.998234 1.1232853 1.0703442 1.188422
##  [5,] 1.122279 1.1055942 1.1095193 1.123285 0.9980054 1.1313959 1.068622
##  [6,] 1.018279 1.1221119 1.1385559 1.070344 1.1313959 0.9987885 1.096782
##  [7,] 1.052375 1.1441651 1.0880298 1.188422 1.0686224 1.0967819 0.998387
##  [8,] 1.050973 1.1407021 1.1192415 1.143900 1.0608612 1.0445771 1.059006
##  [9,] 1.026094 1.1091142 1.1202772 1.085074 1.0692282 1.0347099 1.056453
## [10,] 1.018515 1.0991969 1.1148041 1.083255 1.1005938 1.0159689 1.066786
## [11,] 1.028162 1.0799176 1.0830436 1.054385 1.0484167 1.0415429 1.052100
## [12,] 1.017811 1.0771486 1.1298051 1.069062 1.0857411 1.0112512 1.052883
## [13,] 1.022233 1.0706769 1.0874949 1.066030 1.0461111 1.0212945 1.043237
## [14,] 1.015402 1.0493700 1.1125706 1.095574 1.0747928 1.0237354 1.036797
## [15,] 1.084048 1.1237585 1.0915291 1.048040 1.1174138 1.0540293 1.046770
## [16,] 1.038491 1.0584445 1.1718432 1.019212 1.1616120 1.0184717 1.101882
## [17,] 1.088311 1.0778645 1.1424479 1.152100 1.1968877 1.0431616 1.238424
## [18,] 1.114268 1.1312396 1.1564149 1.082903 1.0558329 1.0836490 1.107912
## [19,] 1.034044 1.1233914 1.0493727 1.098512 1.0978271 1.2066123 1.088365
## [20,] 1.085652 1.2750851 1.3034938 1.137552 1.2256115 1.0498161 1.119712
##            [,8]      [,9]     [,10]     [,11]     [,12]     [,13]
##  [1,] 1.0509727 1.0260941 1.0185147 1.0281622 1.0178113 1.0222332
##  [2,] 1.1407021 1.1091142 1.0991969 1.0799176 1.0771486 1.0706769
##  [3,] 1.1192415 1.1202772 1.1148041 1.0830436 1.1298051 1.0874949
##  [4,] 1.1439004 1.0850742 1.0832551 1.0543853 1.0690624 1.0660298
##  [5,] 1.0608612 1.0692282 1.1005938 1.0484167 1.0857411 1.0461111
##  [6,] 1.0445771 1.0347099 1.0159689 1.0415429 1.0112512 1.0212945
##  [7,] 1.0590061 1.0564529 1.0667857 1.0520999 1.0528831 1.0432370
##  [8,] 0.9981886 1.0205666 1.0140835 1.0150619 1.0160461 1.0079195
##  [9,] 1.0205666 0.9979412 1.0076255 1.0053350 1.0039684 0.9995601
## [10,] 1.0140835 1.0076255 0.9993447 1.0176658 1.0018828 1.0048962
## [11,] 1.0150619 1.0053350 1.0176658 0.9993772 1.0085249 1.0050172
## [12,] 1.0160461 1.0039684 1.0018828 1.0085249 0.9980083 1.0040642
## [13,] 1.0079195 0.9995601 1.0048962 1.0050172 1.0040642 0.9981715
## [14,] 1.0182912 1.0065231 1.0145350 1.0129238 1.0055573 1.0263698
## [15,] 1.0286417 1.0165496 1.0294713 1.0367012 1.0320610 1.0396031
## [16,] 1.0578753 1.0230808 1.0252637 1.0424447 1.0133924 1.0258492
## [17,] 1.1408138 1.1087298 1.0691109 1.1248860 1.0710791 1.0689701
## [18,] 1.0667858 1.0399875 1.0891331 1.0255222 1.0601065 1.0276681
## [19,] 1.1693710 1.1506484 1.1285483 1.1265122 1.1203244 1.1267177
## [20,] 1.1074126 1.0605111 1.0761721 1.0777079 1.0478400 1.0498025
##           [,14]     [,15]     [,16]    [,17]     [,18]     [,19]    [,20]
##  [1,] 1.0154020 1.0840476 1.0384909 1.088311 1.1142685 1.0340445 1.085652
##  [2,] 1.0493700 1.1237585 1.0584445 1.077865 1.1312396 1.1233914 1.275085
##  [3,] 1.1125706 1.0915291 1.1718432 1.142448 1.1564149 1.0493727 1.303494
##  [4,] 1.0955736 1.0480404 1.0192119 1.152100 1.0829030 1.0985119 1.137552
##  [5,] 1.0747928 1.1174138 1.1616120 1.196888 1.0558329 1.0978271 1.225611
##  [6,] 1.0237354 1.0540293 1.0184717 1.043162 1.0836490 1.2066123 1.049816
##  [7,] 1.0367971 1.0467703 1.1018823 1.238424 1.1079122 1.0883652 1.119712
##  [8,] 1.0182912 1.0286417 1.0578753 1.140814 1.0667858 1.1693710 1.107413
##  [9,] 1.0065231 1.0165496 1.0230808 1.108730 1.0399875 1.1506484 1.060511
## [10,] 1.0145350 1.0294713 1.0252637 1.069111 1.0891331 1.1285483 1.076172
## [11,] 1.0129238 1.0367012 1.0424447 1.124886 1.0255222 1.1265122 1.077708
## [12,] 1.0055573 1.0320610 1.0133924 1.071079 1.0601065 1.1203244 1.047840
## [13,] 1.0263698 1.0396031 1.0258492 1.068970 1.0276681 1.1267177 1.049803
## [14,] 0.9979319 1.0482662 1.0345494 1.088266 1.0844502 1.1132210 1.075446
## [15,] 1.0482662 0.9983997 1.0118631 1.056069 1.0527037 1.2673616 1.029722
## [16,] 1.0345494 1.0118631 0.9977275 1.052909 1.0195699 1.1513718 1.018715
## [17,] 1.0882658 1.0560688 1.0529093 0.998596 1.1024259 1.0217043 1.110433
## [18,] 1.0844502 1.0527037 1.0195699 1.102426 0.9978386 1.2679677 1.082628
## [19,] 1.1132210 1.2673616 1.1513718 1.021704 1.2679677 0.9979547 1.323612
## [20,] 1.0754465 1.0297215 1.0187147 1.110433 1.0826283 1.3236117 0.998777
me20$n.eff
## $B
##       [,1] [,2] [,3]
##  [1,]  114  142  148
##  [2,]   39   89   30
##  [3,]   21   99   21
##  [4,]   23   30   22
##  [5,]   26   46   30
##  [6,]   88  141   85
##  [7,]   39   35   42
##  [8,]  675  220   85
##  [9,] 1000  265 1000
## [10,]  674  700  218
## [11,]  598  276 1000
## [12,]  180  413  334
## [13,]  438  378  386
## [14,]  366  129  155
## [15,]   56   44   83
## [16,]   53   97   63
## [17,]   23   45   26
## [18,]   42   59   30
## [19,]   19   68   21
## [20,]   37  116   30
## 
## $Rho
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
##  [1,]    1  181  118  141   73   46   71   89  138    25    49    63   247
##  [2,]  181    1   78  200  111   18  147  186   58    40   121    74    37
##  [3,]  118   78    1   76   43   28   20   59  124   212    85    91    74
##  [4,]  141  200   76    1  354  143  269  122  173    42    66    90    29
##  [5,]   73  111   43  354    1  533  128  100  189   370   176    57    42
##  [6,]   46   18   28  143  533    1  661   73  175    97   963    78    68
##  [7,]   71  147   20  269  128  661    1  212  143   324   100    84   125
##  [8,]   89  186   59  122  100   73  212    1  107   395   156   115   115
##  [9,]  138   58  124  173  189  175  143  107    1   813   131   143   109
## [10,]   25   40  212   42  370   97  324  395  813     1   106    67    49
## [11,]   49  121   85   66  176  963  100  156  131   106     1   431   244
## [12,]   63   74   91   90   57   78   84  115  143    67   431     1   145
## [13,]  247   37   74   29   42   68  125  115  109    49   244   145     1
## [14,]  567  119   24  413   41  348   26  353  197   135   121   178   318
## [15,]  111  174   59  353   54   31   26  295   42    48  1000    66    75
## [16,]   77  136   59   56   76   47  402   80   44   101   245   450    53
## [17,]  105   82   67   58   70  171   44   80   51    43    57    88    30
## [18,]  316  422   58   81  425  152  110  131   55   164   143    72    30
## [19,]   63  212  130  112  125  110  199   78   56    29    81    45    31
## [20,]  143  364  127  489  821  208  563   80  273    74   318   679    58
##       [,14] [,15] [,16] [,17] [,18] [,19] [,20]
##  [1,]   567   111    77   105   316    63   143
##  [2,]   119   174   136    82   422   212   364
##  [3,]    24    59    59    67    58   130   127
##  [4,]   413   353    56    58    81   112   489
##  [5,]    41    54    76    70   425   125   821
##  [6,]   348    31    47   171   152   110   208
##  [7,]    26    26   402    44   110   199   563
##  [8,]   353   295    80    80   131    78    80
##  [9,]   197    42    44    51    55    56   273
## [10,]   135    48   101    43   164    29    74
## [11,]   121  1000   245    57   143    81   318
## [12,]   178    66   450    88    72    45   679
## [13,]   318    75    53    30    30    31    58
## [14,]     1   111   183    58    75    52    86
## [15,]   111     1   221   274    60   333    59
## [16,]   183   221     1   128    70   469   101
## [17,]    58   274   128     1   233   118   159
## [18,]    75    60    70   233     1   117   161
## [19,]    52   333   469   118   117     1   172
## [20,]    86    59   101   159   161   172     1
## 
## $EnvRho
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
##  [1,]    1   99   33   72   38  483  109   72  139   273   137   356   205
##  [2,]   99    1   68  111   59   42   33   28   34    36    43    44    50
##  [3,]   33   68    1   51   48   33   47   31   30    32    41    28    39
##  [4,]   72  111   51    1   36   51   22   27   40    40    60    49    58
##  [5,]   38   59   48   36    1   32   55   57   50    35    66    42    69
##  [6,]  483   42   33   51   32    1   58   70  102   233    76   227   133
##  [7,]  109   33   47   22   55   58    1   65   61    50    67    62    74
##  [8,]   72   28   31   27   57   70   65    1  228   224   195   178   357
##  [9,]  139   34   30   40   50  102   61  228    1   351   520   689  1000
## [10,]  273   36   32   40   35  233   50  224  351     1   169   794   489
## [11,]  137   43   41   60   66   76   67  195  520   169     1   310  1000
## [12,]  356   44   28   49   42  227   62  178  689   794   310     1   856
## [13,]  205   50   39   58   69  133   74  357 1000   489  1000   856     1
## [14,]  312   74   32   37   48  149   91  167  351   214   287   456   201
## [15,]   62   38   43   94   58   90   68  152  184   131   103   114   112
## [16,]  148   62   27  315   28  174   39   56  128   121    76   211   132
## [17,]   58   59   56   30   32   90   20   29   36    56    29    47    48
## [18,]   44   34   25   53   64   42   34   52   77    39   123    57   108
## [19,]  100   37  127   42   53   33   50   23   25    29    30    32    31
## [20,]   46   18   15   29   20   89   35   34   56    47    45    73    68
##       [,14] [,15] [,16] [,17] [,18] [,19] [,20]
##  [1,]   312    62   148    58    44   100    46
##  [2,]    74    38    62    59    34    37    18
##  [3,]    32    43    27    56    25   127    15
##  [4,]    37    94   315    30    53    42    29
##  [5,]    48    58    28    32    64    53    20
##  [6,]   149    90   174    90    42    33    89
##  [7,]    91    68    39    20    34    50    35
##  [8,]   167   152    56    29    52    23    34
##  [9,]   351   184   128    36    77    25    56
## [10,]   214   131   121    56    39    29    47
## [11,]   287   103    76    29   123    30    45
## [12,]   456   114   211    47    57    32    73
## [13,]   201   112   132    48   108    31    68
## [14,]     1    80   101    40    47    33    48
## [15,]    80     1  1000    63   127    19   172
## [16,]   101  1000     1    96   337    27   188
## [17,]    40    63    96     1    33   355    35
## [18,]    47   127   337    33     1    17    42
## [19,]    33    19    27   355    17     1    18
## [20,]    48   172   188    35    42    18     1
me20$mcmc.info[1:7]
## $n.chains
## [1] 5
## 
## $n.adapt
## [1] 250000 250000 250000 250000 250000
## 
## $sufficient.adapt
## [1] FALSE FALSE FALSE FALSE FALSE
## 
## $n.iter
## [1] 20000
## 
## $n.burnin
## [1] 0
## 
## $n.thin
## [1] 100
## 
## $n.samples
## [1] 1000
models<-list(EnvEvenSp20=me20)
mean_correlations<-mean_cor(models)
x <- subset(mean_correlations, type != "Environmental\nFiltering Only")
acc <- by(x, x$model, function(x) sum(x$status == "TP" | x$status == "TN") / nrow(x))

#' Plot correlation parameter means
#+ plot-correlations
ggplot(mean_correlations) +
  aes(factor(nsp), rho, fill = interaction) +
  geom_hline(yintercept = 0) +
  geom_boxplot(
    outlier.size = .2, size = .1, position = position_dodge(preserve = "single")
  ) +
  scale_fill_manual(values = c("grey", "blue", "red")) +
  facet_grid(type ~ rho_type + density, switch = "y") +
  xlab("Number of species") +
  ylab("Correlation") +
  theme_bw() +
  theme(legend.position = "top")

data<-sim_data$EnvEvenSp20
data <- list(
  Y = subset(data, select = -env),
  X = cbind(1, scale(poly(data$env, 2))),
  covx = cov(cbind(1, scale(poly(data$env, 2)))),
  K = 3,
  J = ncol(data) - 1,
  n = nrow(data),
  I = diag(ncol(data) - 1),
  df = ncol(data)
)

##########################################################################################
#Tau<-solve
#Tau_n<-to_prec(me10$mean$Tau)
#Tau_k<-Tau_n*(!(model$q97.5$Tau>0 & model$q2.5$Tau<0))


plot_cor_jsdm(me20,data$Y)

Gjam

data<-sim_data$EnvEvenSp20

#fit_gjam(data,5000,500,"./gjam_models/gjam20env.rda")

load_gjam(data,name="./gjam_models/gjam20env.rda")
## 
## Sensitivity by predictor variables f:
##      Estimate   SE CI_025 CI_975
## env       335 61.7    222    461
## env2      157 28.3    110    219
## 
## Coefficient matrix B:
##             sp01    sp02   sp03   sp04   sp05   sp06   sp07   sp08   sp09
## intercept -0.533  0.0688  0.500  0.144  0.327  0.498  0.720  0.896  0.906
## env       -1.850 -2.5200 -2.480 -2.020 -1.820 -1.760 -1.220 -0.753 -0.516
## env2       0.187  0.3400  0.451 -0.279 -0.507 -0.493 -0.651 -0.641 -0.815
## RMSPE      0.337  0.3000  0.309  0.331  0.332  0.333  0.365  0.398  0.406
##             sp10   sp11   sp12   sp13   sp14   sp15   sp16   sp17     sp18
## intercept  1.130  1.120  1.050  0.689  0.610  0.435  0.440  0.113 -0.07100
## env       -0.200  0.133  0.551  0.870  1.140  1.730  2.460  1.990  2.35000
## env2      -0.931 -0.855 -0.860 -0.794 -0.671 -0.452 -0.227 -0.271  0.00271
## RMSPE      0.398  0.411  0.386  0.399  0.363  0.339  0.308  0.330  0.30300
##              sp19   sp20
## intercept -0.0697 -0.329
## env        2.5800  2.190
## env2       0.3120  0.530
## RMSPE      0.3030  0.318
## 
## Coefficient matrix B:
##                Estimate     SE    CI_025  CI_975 sig95
## sp01_intercept -0.53300 0.1340 -0.764000 -0.3250     *
## sp01_env       -1.85000 0.1340 -2.100000 -1.5800     *
## sp01_env2       0.18700 0.0717  0.055600  0.3320     *
## sp02_intercept  0.06880 0.0972 -0.095900  0.2760      
## sp02_env       -2.52000 0.1560 -2.810000 -2.2200     *
## sp02_env2       0.34000 0.0720  0.206000  0.4840     *
## sp03_intercept  0.50000 0.1040  0.295000  0.6900     *
## sp03_env       -2.48000 0.1360 -2.770000 -2.2400     *
## sp03_env2       0.45100 0.0813  0.310000  0.6170     *
## sp04_intercept  0.14400 0.0783  0.009940  0.3210     *
## sp04_env       -2.02000 0.0913 -2.200000 -1.8400     *
## sp04_env2      -0.27900 0.0825 -0.432000 -0.1160     *
## sp05_intercept  0.32700 0.0843  0.172000  0.4850     *
## sp05_env       -1.82000 0.1010 -2.020000 -1.6200     *
## sp05_env2      -0.50700 0.0716 -0.653000 -0.3720     *
## sp06_intercept  0.49800 0.0786  0.342000  0.6400     *
## sp06_env       -1.76000 0.0786 -1.920000 -1.6100     *
## sp06_env2      -0.49300 0.0669 -0.631000 -0.3680     *
## sp07_intercept  0.72000 0.0628  0.598000  0.8430     *
## sp07_env       -1.22000 0.0844 -1.370000 -1.0500     *
## sp07_env2      -0.65100 0.0816 -0.819000 -0.4980     *
## sp08_intercept  0.89600 0.0702  0.766000  1.0400     *
## sp08_env       -0.75300 0.0678 -0.886000 -0.6230     *
## sp08_env2      -0.64100 0.0614 -0.759000 -0.5180     *
## sp09_intercept  0.90600 0.0712  0.776000  1.0500     *
## sp09_env       -0.51600 0.0835 -0.663000 -0.3500     *
## sp09_env2      -0.81500 0.0669 -0.942000 -0.6790     *
## sp10_intercept  1.13000 0.0655  1.000000  1.2600     *
## sp10_env       -0.20000 0.0573 -0.305000 -0.0862     *
## sp10_env2      -0.93100 0.0676 -1.060000 -0.8010     *
## sp11_intercept  1.12000 0.0684  0.987000  1.2500     *
## sp11_env        0.13300 0.0565  0.022800  0.2410     *
## sp11_env2      -0.85500 0.0630 -0.978000 -0.7310     *
## sp12_intercept  1.05000 0.0730  0.906000  1.2000     *
## sp12_env        0.55100 0.0747  0.420000  0.7010     *
## sp12_env2      -0.86000 0.0752 -1.010000 -0.7180     *
## sp13_intercept  0.68900 0.0591  0.570000  0.8000     *
## sp13_env        0.87000 0.0813  0.709000  1.0300     *
## sp13_env2      -0.79400 0.0668 -0.922000 -0.6560     *
## sp14_intercept  0.61000 0.0641  0.481000  0.7300     *
## sp14_env        1.14000 0.0675  1.020000  1.2800     *
## sp14_env2      -0.67100 0.0665 -0.800000 -0.5470     *
## sp15_intercept  0.43500 0.0588  0.325000  0.5530     *
## sp15_env        1.73000 0.1250  1.520000  1.9800     *
## sp15_env2      -0.45200 0.0641 -0.579000 -0.3340     *
## sp16_intercept  0.44000 0.0521  0.337000  0.5420     *
## sp16_env        2.46000 0.1050  2.260000  2.6700     *
## sp16_env2      -0.22700 0.0501 -0.323000 -0.1280     *
## sp17_intercept  0.11300 0.0563  0.000618  0.2230     *
## sp17_env        1.99000 0.1310  1.760000  2.2600     *
## sp17_env2      -0.27100 0.0645 -0.394000 -0.1480     *
## sp18_intercept -0.07100 0.0549 -0.181000  0.0357      
## sp18_env        2.35000 0.1040  2.140000  2.5500     *
## sp18_env2       0.00271 0.0659 -0.130000  0.1260      
## sp19_intercept -0.06970 0.0875 -0.241000  0.0747      
## sp19_env        2.58000 0.1220  2.350000  2.8300     *
## sp19_env2       0.31200 0.0517  0.216000  0.4120     *
## sp20_intercept -0.32900 0.0556 -0.433000 -0.2160     *
## sp20_env        2.19000 0.0953  2.010000  2.3800     *
## sp20_env2       0.53000 0.0616  0.409000  0.6490     *
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
## Coefficient matrix B, standardized for X:
## NULL
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
## Coefficient matrix B, standardized for X and W:
## NULL
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
##  Design Table
##      env env2
## VIF    1    1
## env2   0   NA
## 
##  Sample contains n = 500 observations on S = 20 response variables, and 2 predictors.  Data types (typeNames) include PA. There are 0 missing values in X and 0 missing values in Y. The RMSPE is 0.351, and the DIC is 371075.  Computation involved 5000 Gibbs steps, with a burnin of 500.

#gje20<-load_object("./gjam_models/gjam20env.rda")

#to check posterior density of s in Sigma 
#gje20<-load_object("./gjam_models/gjam20env.rda")
#plot(density(gje20$chains$sgibbs[,4]))
data<-sim_data$EnvEvenSp20
hm_mod<-fit_hmsc(data,"L_d",name="./HMmodels/hm20env.rda" )
hm_conv(hm_mod)

hm_inter(hm_mod)

Environmental filtering + Facilitation dense 5 species

JSDM

mf5 <- load_object("model-2019-04-11-19-35-11.rda")
summary(mf5)
## Summary for model '/tmp/RtmpKix4lZ/file40e94e482135'
## Saved parameters: B Rho EnvRho 
## MCMC ran in parallel for 29.13 minutes at time 2019-04-11 19:06:03.
## 
## For each of 5 chains:
## Adaptation:            250000 iterations (possibly insufficient)
## Burn-in:               0 iterations
## Thin rate:             100 iterations
## Total chain length:    270000 iterations
## Posterior sample size: 200 draws
## 
## **WARNING** Rhat values indicate convergence failure.
mf5$Rhat
## $B
##          [,1]     [,2]     [,3]
## [1,] 1.061476 1.078281 1.059637
## [2,] 1.050432 1.005249 1.036787
## [3,] 1.029274 1.008142 1.034895
## [4,] 1.308137 1.303643 1.281245
## [5,] 1.024599 1.020683 1.020340
## 
## $Rho
##           [,1]      [,2]      [,3]     [,4]     [,5]
## [1,] 0.9977828 1.0807830 1.0748954 1.002567 1.054513
## [2,] 1.0807830 0.9985899 1.0379842 1.021748 1.007209
## [3,] 1.0748954 1.0379842 0.9978763 1.021928 1.029875
## [4,] 1.0025674 1.0217483 1.0219278 0.998774 1.030838
## [5,] 1.0545132 1.0072085 1.0298750 1.030838       NA
## 
## $EnvRho
##           [,1]      [,2]      [,3]      [,4]      [,5]
## [1,] 0.9996754 1.0312709 1.0567699 1.0928409 1.0541784
## [2,] 1.0312709 0.9976507 1.0200860 1.1323921 1.0501329
## [3,] 1.0567699 1.0200860 0.9978892 1.1094268 1.0149056
## [4,] 1.0928409 1.1323921 1.1094268 0.9996634 1.1421120
## [5,] 1.0541784 1.0501329 1.0149056 1.1421120 0.9992363
mf5$n.eff
## $B
##      [,1] [,2] [,3]
## [1,]   61   47   57
## [2,]   75  496   90
## [3,]  117  305  106
## [4,]   15   15   16
## [5,]  137  161  170
## 
## $Rho
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    1   44   44  678   61
## [2,]   44    1   88  199  334
## [3,]   44   88    1  282  110
## [4,]  678  199  282    1  171
## [5,]   61  334  110  171    1
## 
## $EnvRho
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    1  102   59   41   63
## [2,]  102    1  156   33  102
## [3,]   59  156    1   35  225
## [4,]   41   33   35    1   34
## [5,]   63  102  225   34    1
mf5$mcmc.info[1:7]
## $n.chains
## [1] 5
## 
## $n.adapt
## [1] 250000 250000 250000 250000 250000
## 
## $sufficient.adapt
## [1] FALSE FALSE FALSE FALSE FALSE
## 
## $n.iter
## [1] 20000
## 
## $n.burnin
## [1] 0
## 
## $n.thin
## [1] 100
## 
## $n.samples
## [1] 1000
models<-list(FacDenseSp5=mf5)
mean_correlations<-mean_cor(models)
x <- subset(mean_correlations, type != "Environmental\nFiltering Only")
acc <- by(x, x$model, function(x) sum(x$status == "TP" | x$status == "TN") / nrow(x))

#' Plot correlation parameter means
#+ plot-correlations
ggplot(mean_correlations) +
  aes(factor(nsp), rho, fill = interaction) +
  geom_hline(yintercept = 0) +
  geom_boxplot(
    outlier.size = .2, size = .1, position = position_dodge(preserve = "single")
  ) +
  scale_fill_manual(values = c("grey", "blue", "red")) +
  facet_grid(type ~ rho_type + density, switch = "y") +
  xlab("Number of species") +
  ylab("Correlation") +
  theme_bw() +
  theme(legend.position = "top")

data<-sim_data$FacDenseSp5
data <- list(
  Y = subset(data, select = -env),
  X = cbind(1, scale(poly(data$env, 2))),
  covx = cov(cbind(1, scale(poly(data$env, 2)))),
  K = 3,
  J = ncol(data) - 1,
  n = nrow(data),
  I = diag(ncol(data) - 1),
  df = ncol(data)
)

##########################################################################################
#Tau<-solve
#Tau_n<-to_prec(me10$mean$Tau)
#Tau_k<-Tau_n*(!(model$q97.5$Tau>0 & model$q2.5$Tau<0))

plot_cor_jsdm(mf5,data$Y,fac_inter[[4]])

Gjam

data<-sim_data$FacDenseSp5

#fit_gjam(data,5000,500,"./gjam_models/gjam5f.rda",interact=fac_inter[[4]])
load_gjam(data,name="./gjam_models/gjam5f.rda", interact=fac_inter[[4]])
## 
## Sensitivity by predictor variables f:
##      Estimate   SE CI_025 CI_975
## env     113.0 61.5   13.9    237
## env2     67.7 31.3   19.6    134
## 
## Coefficient matrix B:
##             sp01   sp02   sp03  sp04   sp05
## intercept -1.300  1.020  2.990 1.570 -1.840
## env       -1.540 -1.640  0.114 2.570  1.760
## env2       0.558 -0.451 -1.120 0.308  0.299
## RMSPE      0.308  0.315  0.201 0.331  0.308
## 
## Coefficient matrix B:
##                Estimate     SE  CI_025 CI_975 sig95
## sp01_intercept   -1.300 0.0975 -1.4900 -1.110     *
## sp01_env         -1.540 0.1450 -1.8300 -1.300     *
## sp01_env2         0.558 0.0909  0.3960  0.749     *
## sp02_intercept    1.020 0.1180  0.8440  1.300     *
## sp02_env         -1.640 0.0966 -1.8200 -1.450     *
## sp02_env2        -0.451 0.0802 -0.6250 -0.298     *
## sp03_intercept    2.990 0.1230  2.7500  3.230     *
## sp03_env          0.114 0.0787 -0.0114  0.287      
## sp03_env2        -1.120 0.0715 -1.2600 -0.977     *
## sp04_intercept    1.570 0.0908  1.4100  1.770     *
## sp04_env          2.570 0.1370  2.3300  2.870     *
## sp04_env2         0.308 0.0514  0.2070  0.410     *
## sp05_intercept   -1.840 0.1750 -2.1700 -1.510     *
## sp05_env          1.760 0.1520  1.4600  2.060     *
## sp05_env2         0.299 0.0823  0.1450  0.448     *
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
## Coefficient matrix B, standardized for X:
## NULL
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
## Coefficient matrix B, standardized for X and W:
## NULL
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
##  Design Table
##      env env2
## VIF    1    1
## env2   0   NA
## 
##  Sample contains n = 500 observations on S = 5 response variables, and 2 predictors.  Data types (typeNames) include PA. There are 0 missing values in X and 0 missing values in Y. The RMSPE is 0.296, and the DIC is 80408.  Computation involved 5000 Gibbs steps, with a burnin of 500.

#gjfd5<-load_object("./gjam_models/gjam5f.rda")

#to check posterior density of s in Sigma 
#gjfd5<-load_object("./gjam_models/gjam5f.rda")
#plot(density(gjfd5$chains$sgibbs[,4]))

HMSC

data<-sim_data$FacDenseSp5
hm_mod<-fit_hmsc(data,"L_d",name="./HMmodels/hm5fd.rda" )
hm_conv(hm_mod)

hm_inter(hm_mod, interact = fac_inter[[4]])

Environmental filtering + Facilitation dense 10 species

JSDM

## Summary for model '/tmp/RtmpKix4lZ/file40e96d09e31e'
## Saved parameters: B Rho EnvRho 
## MCMC ran in parallel for 684.487 minutes at time 2019-04-11 19:35:12.
## 
## For each of 5 chains:
## Adaptation:            250000 iterations (possibly insufficient)
## Burn-in:               0 iterations
## Thin rate:             100 iterations
## Total chain length:    270000 iterations
## Posterior sample size: 200 draws
## 
## **WARNING** Rhat values indicate convergence failure.
## $B
##           [,1]      [,2]     [,3]
##  [1,] 1.153482 1.0336151 1.192794
##  [2,] 1.133619 1.1411694 1.148770
##  [3,] 1.012998 1.0148224 1.007833
##  [4,] 1.178132 1.1516477 1.197430
##  [5,] 1.002237 0.9999322 1.002150
##  [6,] 1.190968 1.2109106 1.129494
##  [7,] 1.009794 1.0040941 1.047714
##  [8,] 1.007133 1.0052821 1.001169
##  [9,] 1.285740 1.2434730 1.228175
## [10,] 1.217415 1.1142643 1.286613
## 
## $Rho
##            [,1]     [,2]     [,3]      [,4]      [,5]      [,6]      [,7]
##  [1,] 0.9988733 1.031197 1.019898 1.0812913 1.0137249 1.0637758 1.0129501
##  [2,] 1.0311967 0.998210 1.012831 1.1195132 1.0044466 1.0592694 1.0033491
##  [3,] 1.0198982 1.012831 1.000408 1.0126902 1.0020036 1.0024656 1.0622998
##  [4,] 1.0812913 1.119513 1.012690 0.9979297 1.0068483 1.0407943 1.0110697
##  [5,] 1.0137249 1.004447 1.002004 1.0068483 0.9981162 1.0124882 1.0166292
##  [6,] 1.0637758 1.059269 1.002466 1.0407943 1.0124882 0.9978665 1.0831663
##  [7,] 1.0129501 1.003349 1.062300 1.0110697 1.0166292 1.0831663 0.9984459
##  [8,] 1.0272182 1.013482 1.000281 1.0123064 1.0047824 1.1064121 1.0145070
##  [9,] 1.0109590 1.011512 1.022300 1.0414561 1.0053878 1.1066725 1.0033029
## [10,] 1.0369179 1.009054 1.002782 1.0435671 1.0080731 1.0504700 1.0603705
##            [,8]      [,9]    [,10]
##  [1,] 1.0272182 1.0109590 1.036918
##  [2,] 1.0134820 1.0115116 1.009054
##  [3,] 1.0002814 1.0222999 1.002782
##  [4,] 1.0123064 1.0414561 1.043567
##  [5,] 1.0047824 1.0053878 1.008073
##  [6,] 1.1064121 1.1066725 1.050470
##  [7,] 1.0145070 1.0033029 1.060371
##  [8,] 0.9984815 0.9990499 1.005105
##  [9,] 0.9990499 0.9982693 1.019467
## [10,] 1.0051052 1.0194674       NA
## 
## $EnvRho
##            [,1]      [,2]      [,3]     [,4]      [,5]      [,6]      [,7]
##  [1,] 0.9979932 1.0620907 1.1552389 1.126374 1.0815389 1.1780759 1.0943292
##  [2,] 1.0620907 0.9976796 1.0557414 1.081622 1.0590928 1.1310287 1.0309328
##  [3,] 1.1552389 1.0557414 0.9986019 1.173177 1.0027567 1.1664742 1.0132200
##  [4,] 1.1263736 1.0816223 1.1731773 1.000214 1.1261088 1.1220314 1.1087357
##  [5,] 1.0815389 1.0590928 1.0027567 1.126109 0.9984384 1.1508615 1.0172239
##  [6,] 1.1780759 1.1310287 1.1664742 1.122031 1.1508615 0.9982952 1.0915563
##  [7,] 1.0943292 1.0309328 1.0132200 1.108736 1.0172239 1.0915563 0.9984136
##  [8,] 1.1299096 1.0742937 0.9992827 1.116689 1.0021633 1.0489712 1.0108285
##  [9,] 1.3558782 1.4807811 1.2708682 1.181207 1.1392039 1.2012272 1.2274419
## [10,] 1.3150484 1.4503682 1.2632536 1.196921 1.1060001 1.2696838 1.1913738
##            [,8]      [,9]     [,10]
##  [1,] 1.1299096 1.3558782 1.3150484
##  [2,] 1.0742937 1.4807811 1.4503682
##  [3,] 0.9992827 1.2708682 1.2632536
##  [4,] 1.1166894 1.1812072 1.1969212
##  [5,] 1.0021633 1.1392039 1.1060001
##  [6,] 1.0489712 1.2012272 1.2696838
##  [7,] 1.0108285 1.2274419 1.1913738
##  [8,] 0.9985681 1.1882731 1.1307389
##  [9,] 1.1882731 0.9991252 1.0640158
## [10,] 1.1307389 1.0640158 0.9978327
## $B
##       [,1] [,2] [,3]
##  [1,]   25   94   22
##  [2,]   27   26   25
##  [3,]  223  198  394
##  [4,]   24   27   23
##  [5,]  661 1000  896
##  [6,]   22   20   29
##  [7,]  275  464   65
##  [8,]  445  489  889
##  [9,]   16   18   19
## [10,]   19   33   16
## 
## $Rho
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
##  [1,]    1   96  162   47  215   61  204  110  270    93
##  [2,]   96    1  200   34  843   55  883  202  223   443
##  [3,]  162  200    1  272 1000  801   53 1000  132   757
##  [4,]   47   34  272    1  387  126  281  247   83    72
##  [5,]  215  843 1000  387    1  233  210  467  590   357
##  [6,]   61   55  801  126  233    1   41   33   35    71
##  [7,]  204  883   53  281  210   41    1  184  531    55
##  [8,]  110  202 1000  247  467   33  184    1 1000   864
##  [9,]  270  223  132   83  590   35  531 1000    1   161
## [10,]   93  443  757   72  357   71   55  864  161     1
## 
## $EnvRho
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
##  [1,]    1  109   29   42   43   25   42   29   15    15
##  [2,]  109    1   62   60   54   33   98   44   12    12
##  [3,]   29   62    1   26  580   27  200 1000   17    17
##  [4,]   42   60   26    1   30   34   37   32   24    22
##  [5,]   43   54  580   30    1   26  163  740   27    34
##  [6,]   25   33   27   34   26    1   46   88   26    22
##  [7,]   42   98  200   37  163   46    1  499   19    20
##  [8,]   29   44 1000   32  740   88  499    1   22    27
##  [9,]   15   12   17   24   27   26   19   22    1   105
## [10,]   15   12   17   22   34   22   20   27  105     1
## $n.chains
## [1] 5
## 
## $n.adapt
## [1] 250000 250000 250000 250000 250000
## 
## $sufficient.adapt
## [1] FALSE FALSE FALSE FALSE FALSE
## 
## $n.iter
## [1] 20000
## 
## $n.burnin
## [1] 0
## 
## $n.thin
## [1] 100
## 
## $n.samples
## [1] 1000

data<-sim_data$FacDenseSp10

#fit_gjam(data,5000,500,"./gjam_models/gjam10fd.rda",interact=fac_inter[[5]])
load_gjam(data,name="./gjam_models/gjam10fd.rda", interact=fac_inter[[5]])
## 
## Sensitivity by predictor variables f:
##      Estimate    SE CI_025 CI_975
## env     160.0 35.60  101.0    240
## env2     18.5  4.88   10.4     29
## 
## Coefficient matrix B:
##             sp01   sp02   sp03   sp04    sp05   sp06   sp07   sp08  sp09
## intercept  0.212 -1.490 -0.877  2.410 -0.0951  2.400  0.497 -0.401 1.260
## env       -2.760 -2.660 -1.810 -3.010 -0.5910  1.160  1.330  1.030 3.990
## env2       1.070 -0.969 -0.644  0.319 -0.7020 -0.454 -0.256 -0.347 0.095
## RMSPE      0.274  0.375  0.406  0.305  0.4930  0.259  0.390  0.471 0.248
##             sp10
## intercept -0.893
## env        2.250
## env2      -0.411
## RMSPE      0.354
## 
## Coefficient matrix B:
##                Estimate     SE  CI_025  CI_975 sig95
## sp01_intercept   0.2120 0.0687  0.0833  0.3520     *
## sp01_env        -2.7600 0.1740 -3.1200 -2.4700     *
## sp01_env2        1.0700 0.1350  0.8190  1.3200     *
## sp02_intercept  -1.4900 0.2000 -1.9200 -1.1600     *
## sp02_env        -2.6600 0.2110 -3.0900 -2.3000     *
## sp02_env2       -0.9690 0.1130 -1.2400 -0.7780     *
## sp03_intercept  -0.8770 0.1070 -1.0900 -0.6900     *
## sp03_env        -1.8100 0.1470 -2.1200 -1.5700     *
## sp03_env2       -0.6440 0.1190 -0.9250 -0.4570     *
## sp04_intercept   2.4100 0.2040  2.0500  2.8000     *
## sp04_env        -3.0100 0.2470 -3.4600 -2.5900     *
## sp04_env2        0.3190 0.0696  0.1860  0.4540     *
## sp05_intercept  -0.0951 0.0554 -0.2050  0.0147      
## sp05_env        -0.5910 0.0628 -0.7140 -0.4700     *
## sp05_env2       -0.7020 0.0743 -0.8490 -0.5590     *
## sp06_intercept   2.4000 0.1260  2.1600  2.6400     *
## sp06_env         1.1600 0.0761  1.0100  1.3100     *
## sp06_env2       -0.4540 0.0649 -0.5840 -0.3310     *
## sp07_intercept   0.4970 0.0563  0.3840  0.6040     *
## sp07_env         1.3300 0.0797  1.1800  1.4900     *
## sp07_env2       -0.2560 0.0554 -0.3670 -0.1470     *
## sp08_intercept  -0.4010 0.0539 -0.5070 -0.2950     *
## sp08_env         1.0300 0.0877  0.8540  1.1900     *
## sp08_env2       -0.3470 0.0592 -0.4640 -0.2320     *
## sp09_intercept   1.2600 0.0922  1.0900  1.4500     *
## sp09_env         3.9900 0.3810  3.3800  4.6800     *
## sp09_env2        0.0950 0.0613 -0.0361  0.2050      
## sp10_intercept  -0.8930 0.0796 -1.0700 -0.7550     *
## sp10_env         2.2500 0.1280  2.0400  2.5200     *
## sp10_env2       -0.4110 0.0576 -0.5230 -0.2980     *
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
## Coefficient matrix B, standardized for X:
## NULL
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
## Coefficient matrix B, standardized for X and W:
## NULL
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
##  Design Table
##      env env2
## VIF    1    1
## env2   0   NA
## 
##  Sample contains n = 500 observations on S = 10 response variables, and 2 predictors.  Data types (typeNames) include PA. There are 0 missing values in X and 0 missing values in Y. The RMSPE is 0.367, and the DIC is 157914.  Computation involved 5000 Gibbs steps, with a burnin of 500.

#gjfd5<-load_object("./gjam_models/gjam10fd.rda")

#to check posterior density of s in Sigma 
#gjfd5<-load_object("./gjam_models/gjam10fd.rda")
#plot(density(gjfd5$chains$sgibbs[,4]))

HMSC

Environmental filtering + Facilitation dense 20 species

JSDM

## Summary for model '/tmp/RtmpKix4lZ/file40e91ec9ff9'
## Saved parameters: B Rho EnvRho 
## MCMC ran in parallel for 2062.467 minutes at time 2019-04-12 06:59:42.
## 
## For each of 5 chains:
## Adaptation:            250000 iterations (possibly insufficient)
## Burn-in:               0 iterations
## Thin rate:             100 iterations
## Total chain length:    270000 iterations
## Posterior sample size: 200 draws
## 
## **WARNING** Rhat values indicate convergence failure.
## $B
##           [,1]      [,2]     [,3]
##  [1,] 1.376190 1.0558773 1.417312
##  [2,] 1.074703 1.0817636 1.081799
##  [3,] 1.011400 1.0171340 1.034544
##  [4,] 1.613198 1.1296227 1.554124
##  [5,] 1.071209 1.0946053 1.100012
##  [6,] 1.115704 1.1124290 1.100328
##  [7,] 1.007029 1.0154298 1.030331
##  [8,] 1.003984 1.0030036 1.008055
##  [9,] 1.025315 1.0164277 1.012605
## [10,] 1.030228 1.0030305 1.010353
## [11,] 1.004568 0.9990085 1.023995
## [12,] 1.003844 1.0144397 1.006972
## [13,] 1.009875 1.0165315 1.021270
## [14,] 1.062406 1.0196660 1.015510
## [15,] 1.028030 1.0127785 1.021736
## [16,] 1.034695 1.0181825 1.054500
## [17,] 1.094448 1.0257206 1.103735
## [18,] 1.091727 1.0828716 1.065255
## [19,] 1.282707 1.1298502 1.330849
## [20,] 1.168245 1.1176696 1.141811
## 
## $Rho
##            [,1]     [,2]      [,3]      [,4]     [,5]     [,6]      [,7]
##  [1,] 0.9982905 1.008771 1.0061375 1.0788395 1.009030 1.095454 1.0216688
##  [2,] 1.0087715 1.000078 1.0090774 1.0078921 1.105212 1.044087 1.0202222
##  [3,] 1.0061375 1.009077 0.9987511 1.0650208 1.058049 1.033873 1.0162547
##  [4,] 1.0788395 1.007892 1.0650208 0.9986979 1.010182 1.037413 1.1031827
##  [5,] 1.0090298 1.105212 1.0580490 1.0101820 1.000651 1.012787 1.0197768
##  [6,] 1.0954535 1.044087 1.0338730 1.0374131 1.012787 1.000065 1.1114474
##  [7,] 1.0216688 1.020222 1.0162547 1.1031827 1.019777 1.111447 0.9984712
##  [8,] 1.0421743 1.027521 1.0556269 1.0486871 1.004953 1.039428 1.0091695
##  [9,] 1.0491384 1.081933 1.0149809 1.1409019 1.018936 1.025693 1.0197720
## [10,] 1.1607294 1.152438 1.0090012 1.0315944 1.072180 1.009837 1.0226942
## [11,] 1.0169814 1.018941 1.0190009 1.0463823 1.021600 1.077737 1.0310290
## [12,] 1.0288528 1.017582 1.0091793 1.0675219 1.053340 1.068944 1.0162678
## [13,] 1.0171323 1.030387 1.0271916 1.0868156 1.072540 1.018329 1.0495081
## [14,] 1.0116781 1.029884 1.0235713 1.1044660 1.021622 1.016754 1.0454174
## [15,] 1.0294567 1.039518 1.0042398 1.0793017 1.093085 1.068150 1.0240445
## [16,] 1.0050553 1.063294 1.0302294 1.0604339 1.071086 1.051623 1.0097124
## [17,] 1.0076387 1.035886 1.0531829 1.0390297 1.045285 1.006324 1.0176165
## [18,] 1.0263156 1.023363 1.0394359 1.0165522 1.004494 1.021192 1.0133820
## [19,] 1.0257184 1.044273 1.0358410 1.0334129 1.008060 1.045058 1.0217908
## [20,] 1.0174202 1.022821 1.0158514 1.0312164 1.029276 1.010109 1.0375571
##            [,8]      [,9]     [,10]     [,11]    [,12]     [,13]     [,14]
##  [1,] 1.0421743 1.0491384 1.1607294 1.0169814 1.028853 1.0171323 1.0116781
##  [2,] 1.0275208 1.0819326 1.1524381 1.0189412 1.017582 1.0303869 1.0298838
##  [3,] 1.0556269 1.0149809 1.0090012 1.0190009 1.009179 1.0271916 1.0235713
##  [4,] 1.0486871 1.1409019 1.0315944 1.0463823 1.067522 1.0868156 1.1044660
##  [5,] 1.0049532 1.0189364 1.0721797 1.0215999 1.053340 1.0725396 1.0216217
##  [6,] 1.0394279 1.0256935 1.0098367 1.0777371 1.068944 1.0183288 1.0167538
##  [7,] 1.0091695 1.0197720 1.0226942 1.0310290 1.016268 1.0495081 1.0454174
##  [8,] 0.9976755 1.0237740 1.0305832 1.0078299 1.010643 1.0649194 1.0774921
##  [9,] 1.0237740 0.9978824 1.0119416 1.0114924 1.023305 1.0585167 1.0965350
## [10,] 1.0305832 1.0119416 0.9977778 1.0107151 1.007352 1.0154822 1.0262685
## [11,] 1.0078299 1.0114924 1.0107151 0.9985406 1.008055 1.0126642 1.0329052
## [12,] 1.0106433 1.0233055 1.0073519 1.0080548 0.998600 1.0038325 1.0153099
## [13,] 1.0649194 1.0585167 1.0154822 1.0126642 1.003832 0.9984417 1.0176475
## [14,] 1.0774921 1.0965350 1.0262685 1.0329052 1.015310 1.0176475 0.9982314
## [15,] 1.0264074 1.0446357 1.0791844 1.0094512 1.020979 1.0383925 1.0405234
## [16,] 1.0555903 1.1842121 1.1397342 1.0216436 1.006298 1.0972664 1.0329415
## [17,] 1.0300742 1.0740353 1.0692992 1.0268783 1.033863 1.1247628 1.0251688
## [18,] 1.0156435 1.0129000 1.0627640 1.1342464 1.003133 1.0143853 1.0291242
## [19,] 1.0901816 1.1057923 1.0182179 1.0905179 1.064108 1.1310804 1.0205923
## [20,] 1.0233796 1.0089226 1.0785589 1.0240788 1.049107 1.0930434 1.0830906
##          [,15]     [,16]     [,17]     [,18]     [,19]    [,20]
##  [1,] 1.029457 1.0050553 1.0076387 1.0263156 1.0257184 1.017420
##  [2,] 1.039518 1.0632937 1.0358859 1.0233629 1.0442731 1.022821
##  [3,] 1.004240 1.0302294 1.0531829 1.0394359 1.0358410 1.015851
##  [4,] 1.079302 1.0604339 1.0390297 1.0165522 1.0334129 1.031216
##  [5,] 1.093085 1.0710857 1.0452854 1.0044938 1.0080603 1.029276
##  [6,] 1.068150 1.0516226 1.0063242 1.0211920 1.0450582 1.010109
##  [7,] 1.024045 1.0097124 1.0176165 1.0133820 1.0217908 1.037557
##  [8,] 1.026407 1.0555903 1.0300742 1.0156435 1.0901816 1.023380
##  [9,] 1.044636 1.1842121 1.0740353 1.0129000 1.1057923 1.008923
## [10,] 1.079184 1.1397342 1.0692992 1.0627640 1.0182179 1.078559
## [11,] 1.009451 1.0216436 1.0268783 1.1342464 1.0905179 1.024079
## [12,] 1.020979 1.0062975 1.0338630 1.0031331 1.0641080 1.049107
## [13,] 1.038392 1.0972664 1.1247628 1.0143853 1.1310804 1.093043
## [14,] 1.040523 1.0329415 1.0251688 1.0291242 1.0205923 1.083091
## [15,] 1.000352 1.0235770 1.0257166 1.0409805 1.1325189 1.014841
## [16,] 1.023577 0.9989292 1.0153353 1.0267468 1.0378189 1.018608
## [17,] 1.025717 1.0153353 0.9990633 1.0227679 1.0201524 1.012318
## [18,] 1.040981 1.0267468 1.0227679 0.9982089 1.0395519 1.015322
## [19,] 1.132519 1.0378189 1.0201524 1.0395519 0.9980641 1.058135
## [20,] 1.014841 1.0186084 1.0123176 1.0153218 1.0581347       NA
## 
## $EnvRho
##            [,1]      [,2]      [,3]      [,4]      [,5]      [,6]
##  [1,] 0.9981952 1.2962334 1.2590747 1.2779156 1.2378309 1.3021830
##  [2,] 1.2962334 0.9984844 1.0372082 1.4508535 1.0840534 1.1642475
##  [3,] 1.2590747 1.0372082 0.9979626 1.2971322 1.0378016 1.0725820
##  [4,] 1.2779156 1.4508535 1.2971322 0.9982414 1.5080367 1.2888365
##  [5,] 1.2378309 1.0840534 1.0378016 1.5080367 0.9982248 1.1256293
##  [6,] 1.3021830 1.1642475 1.0725820 1.2888365 1.1256293 0.9977014
##  [7,] 1.3350597 1.0791270 1.0259420 1.4350985 1.0567047 1.0763377
##  [8,] 1.3081898 1.0510011 1.0232430 1.4176703 1.0414941 1.0942146
##  [9,] 1.2952902 1.0420498 1.0115281 1.4122190 1.0220795 1.0963735
## [10,] 1.2557836 1.0206197 1.0325317 1.4063176 1.0193963 1.1189370
## [11,] 1.2336963 1.0291512 1.0095906 1.3139512 1.0142752 1.0727224
## [12,] 1.2471062 1.0219431 1.0267858 1.3598573 1.0313201 1.1077870
## [13,] 1.2951416 1.0434651 1.0229407 1.4005936 1.0284676 1.1046606
## [14,] 1.2892076 1.0425613 1.0404888 1.3995243 1.0239503 1.1016006
## [15,] 1.3173507 1.0463249 1.0206049 1.4129646 1.0374952 1.1162183
## [16,] 1.3065375 1.1447487 1.0209884 1.2939394 1.0860556 1.0349452
## [17,] 1.0642736 1.0370507 1.0452255 1.2032613 1.0413651 1.1090956
## [18,] 1.2265997 1.0945057 1.0404913 1.3383348 1.0987603 1.0791234
## [19,] 1.1659138 1.1965960 1.2699753 1.1224340 1.1966557 1.1954237
## [20,] 1.2164226 1.0768137 1.0783577 1.3002161 1.0899083 1.2215159
##            [,7]      [,8]      [,9]     [,10]     [,11]     [,12]
##  [1,] 1.3350597 1.3081898 1.2952902 1.2557836 1.2336963 1.2471062
##  [2,] 1.0791270 1.0510011 1.0420498 1.0206197 1.0291512 1.0219431
##  [3,] 1.0259420 1.0232430 1.0115281 1.0325317 1.0095906 1.0267858
##  [4,] 1.4350985 1.4176703 1.4122190 1.4063176 1.3139512 1.3598573
##  [5,] 1.0567047 1.0414941 1.0220795 1.0193963 1.0142752 1.0313201
##  [6,] 1.0763377 1.0942146 1.0963735 1.1189370 1.0727224 1.1077870
##  [7,] 0.9978644 1.0082685 1.0164318 1.0132323 1.0016842 1.0105357
##  [8,] 1.0082685 0.9980743 1.0021699 1.0068113 0.9982225 1.0056340
##  [9,] 1.0164318 1.0021699 0.9981867 1.0094352 0.9993050 1.0061733
## [10,] 1.0132323 1.0068113 1.0094352 0.9978899 1.0034264 1.0008559
## [11,] 1.0016842 0.9982225 0.9993050 1.0034264 0.9985240 1.0019659
## [12,] 1.0105357 1.0056340 1.0061733 1.0008559 1.0019659 0.9979893
## [13,] 1.0178895 1.0100388 1.0006110 1.0067462 1.0015960 1.0061658
## [14,] 1.0074721 1.0039539 1.0103291 1.0046501 1.0037454 1.0109154
## [15,] 1.0232224 1.0111400 1.0012612 1.0122250 1.0044454 1.0063018
## [16,] 1.0374900 1.0444998 1.0403165 1.0612613 1.0251882 1.0571402
## [17,] 1.1080038 1.0887064 1.0542962 1.0643649 1.0657425 1.0645492
## [18,] 1.0168118 1.0231071 1.0289775 1.0238655 1.0157642 1.0206559
## [19,] 1.2624819 1.2615101 1.2275395 1.1811468 1.1792001 1.1674168
## [20,] 1.1441809 1.1222947 1.1087246 1.0938808 1.0938538 1.1127080
##           [,13]     [,14]     [,15]     [,16]     [,17]     [,18]
##  [1,] 1.2951416 1.2892076 1.3173507 1.3065375 1.0642736 1.2265997
##  [2,] 1.0434651 1.0425613 1.0463249 1.1447487 1.0370507 1.0945057
##  [3,] 1.0229407 1.0404888 1.0206049 1.0209884 1.0452255 1.0404913
##  [4,] 1.4005936 1.3995243 1.4129646 1.2939394 1.2032613 1.3383348
##  [5,] 1.0284676 1.0239503 1.0374952 1.0860556 1.0413651 1.0987603
##  [6,] 1.1046606 1.1016006 1.1162183 1.0349452 1.1090956 1.0791234
##  [7,] 1.0178895 1.0074721 1.0232224 1.0374900 1.1080038 1.0168118
##  [8,] 1.0100388 1.0039539 1.0111400 1.0444998 1.0887064 1.0231071
##  [9,] 1.0006110 1.0103291 1.0012612 1.0403165 1.0542962 1.0289775
## [10,] 1.0067462 1.0046501 1.0122250 1.0612613 1.0643649 1.0238655
## [11,] 1.0015960 1.0037454 1.0044454 1.0251882 1.0657425 1.0157642
## [12,] 1.0061658 1.0109154 1.0063018 1.0571402 1.0645492 1.0206559
## [13,] 0.9987243 1.0084284 1.0005957 1.0399168 1.0839167 1.0351159
## [14,] 1.0084284 0.9978177 1.0145308 1.0584693 1.0978121 1.0392557
## [15,] 1.0005957 1.0145308 0.9981296 1.0507099 1.0809332 1.0317971
## [16,] 1.0399168 1.0584693 1.0507099 0.9987887 1.1996512 1.0346758
## [17,] 1.0839167 1.0978121 1.0809332 1.1996512 0.9978612 1.1058675
## [18,] 1.0351159 1.0392557 1.0317971 1.0346758 1.1058675 0.9981475
## [19,] 1.2385736 1.1963221 1.2338101 1.3474897 1.0857633 1.1838293
## [20,] 1.1313576 1.1321472 1.1332496 1.1639659 1.0402368 1.2256711
##           [,19]     [,20]
##  [1,] 1.1659138 1.2164226
##  [2,] 1.1965960 1.0768137
##  [3,] 1.2699753 1.0783577
##  [4,] 1.1224340 1.3002161
##  [5,] 1.1966557 1.0899083
##  [6,] 1.1954237 1.2215159
##  [7,] 1.2624819 1.1441809
##  [8,] 1.2615101 1.1222947
##  [9,] 1.2275395 1.1087246
## [10,] 1.1811468 1.0938808
## [11,] 1.1792001 1.0938538
## [12,] 1.1674168 1.1127080
## [13,] 1.2385736 1.1313576
## [14,] 1.1963221 1.1321472
## [15,] 1.2338101 1.1332496
## [16,] 1.3474897 1.1639659
## [17,] 1.0857633 1.0402368
## [18,] 1.1838293 1.2256711
## [19,] 0.9980883 1.1118400
## [20,] 1.1118400 0.9977901
## $B
##       [,1] [,2] [,3]
##  [1,]   13   57   12
##  [2,]   46   42   42
##  [3,]  301  176   90
##  [4,]   10   29   10
##  [5,]   46   37   35
##  [6,]   34   32   37
##  [7,]  536  181  102
##  [8,]  868 1000  388
##  [9,]  121  172  238
## [10,]  100  625  303
## [11,]  499 1000  121
## [12,] 1000  184  395
## [13,]  269  166  153
## [14,]   54  149  179
## [15,]  112  231  138
## [16,]  108  227   63
## [17,]   42  117   37
## [18,]   44   43   71
## [19,]   16   29   14
## [20,]   23   31   27
## 
## $Rho
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
##  [1,]    1  353  436   46  381   42  169   83   93    24   171   130   160
##  [2,]  353    1  392  339   33   80  150  134   41    26   184   175   106
##  [3,]  436  392    1   51   59  101  171   59  297   569   166   359   111
##  [4,]   46  339   51    1 1000   90   35   68   27   118    78    50    40
##  [5,]  381   33   59 1000    1  269  156  867  283    48   130    61    46
##  [6,]   42   80  101   90  269    1   33   79  162   336    44    51   220
##  [7,]  169  150  171   35  156   33    1  303  143   127    97   190    66
##  [8,]   83  134   59   68  867   79  303    1  147   109   472   344    52
##  [9,]   93   41  297   27  283  162  143  147    1   292   314   137    62
## [10,]   24   26  569  118   48  336  127  109  292     1   367   362   180
## [11,]  171  184  166   78  130   44   97  472  314   367     1   326   229
## [12,]  130  175  359   50   61   51  190  344  137   362   326     1  1000
## [13,]  160  106  111   40   46  220   66   52   62   180   229  1000     1
## [14,]  243  134  169   37  160  166   73   44   36   131   100   182   173
## [15,]  113   82  622   46   37   51  136  145   72    46   273   159    85
## [16,]  555   52  111   58   47   64  285   64   22    28   151   525    36
## [17,]  360   84   62   79   73  569  191  106   45    52   120   102    29
## [18,]  129  128   86  191  621  197  226  202  257    53    32  1000   817
## [19,]  119   73  102  119  348   70  168   41   35   163    41    52    29
## [20,]  190  194  199  117  127  376   84  122  674    46   124    70    40
##       [,14] [,15] [,16] [,17] [,18] [,19] [,20]
##  [1,]   243   113   555   360   129   119   190
##  [2,]   134    82    52    84   128    73   194
##  [3,]   169   622   111    62    86   102   199
##  [4,]    37    46    58    79   191   119   117
##  [5,]   160    37    47    73   621   348   127
##  [6,]   166    51    64   569   197    70   376
##  [7,]    73   136   285   191   226   168    84
##  [8,]    44   145    64   106   202    41   122
##  [9,]    36    72    22    45   257    35   674
## [10,]   131    46    28    52    53   163    46
## [11,]   100   273   151   120    32    41   124
## [12,]   182   159   525   102  1000    52    70
## [13,]   173    85    36    29   817    29    40
## [14,]     1    90    96   127   116   154    43
## [15,]    90     1   127   137    82    28   237
## [16,]    96   127     1   279   122    95   192
## [17,]   127   137   279     1   136   151   227
## [18,]   116    82   122   136     1    90   236
## [19,]   154    28    95   151    90     1    57
## [20,]    43   237   192   227   236    57     1
## 
## $EnvRho
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
##  [1,]    1   16   18   17   18   15   14   15   15    17    18    17    15
##  [2,]   16    1  105   12   62   36   45   71   75   190   103   139    74
##  [3,]   18  105    1   17   87   57  112  130  220    93   266   109   139
##  [4,]   17   12   17    1   11   17   12   12   12    12    15    13    12
##  [5,]   18   62   87   11    1   43   62   92  135   162   193   102   124
##  [6,]   15   36   57   17   43    1   48   39   39    32    47    33    35
##  [7,]   14   45  112   12   62   48    1  551  219   209   874   259   208
##  [8,]   15   71  130   12   92   39  551    1  755   425  1000   409   416
##  [9,]   15   75  220   12  135   39  219  755    1   407  1000   501  1000
## [10,]   17  190   93   12  162   32  209  425  407     1   668  1000   340
## [11,]   18  103  266   15  193   47  874 1000 1000   668     1   708  1000
## [12,]   17  139  109   13  102   33  259  409  501  1000   708     1   554
## [13,]   15   74  139   12  124   35  208  416 1000   340  1000   554     1
## [14,]   15   78   76   12  133   36  314  516  264   557   591   322   306
## [15,]   14   72  147   12   83   32  133  231 1000   222   611   434  1000
## [16,]   15   26  138   15   40   93   84   70   78    53   119    59    78
## [17,]   80   89   71   23   76   41   35   42   64    55    57    57    50
## [18,]   19   44   92   16   39   44  230  151  136   127   223   241   132
## [19,]   32   22   17   38   21   23   17   17   18    22    22    23    18
## [20,]   21   78   48   17   40   21   27   31   34    39    38    34    30
##       [,14] [,15] [,16] [,17] [,18] [,19] [,20]
##  [1,]    15    14    15    80    19    32    21
##  [2,]    78    72    26    89    44    22    78
##  [3,]    76   147   138    71    92    17    48
##  [4,]    12    12    15    23    16    38    17
##  [5,]   133    83    40    76    39    21    40
##  [6,]    36    32    93    41    44    23    21
##  [7,]   314   133    84    35   230    17    27
##  [8,]   516   231    70    42   151    17    31
##  [9,]   264  1000    78    64   136    18    34
## [10,]   557   222    53    55   127    22    39
## [11,]   591   611   119    57   223    22    38
## [12,]   322   434    59    57   241    23    34
## [13,]   306  1000    78    50   132    18    30
## [14,]     1   248    61    40   106    21    29
## [15,]   248     1    63    54   124    18    30
## [16,]    61    63     1    29   124    14    24
## [17,]    40    54    29     1    49    59   112
## [18,]   106   124   124    49     1    23    25
## [19,]    21    18    14    59    23     1    42
## [20,]    29    30    24   112    25    42     1
## $n.chains
## [1] 5
## 
## $n.adapt
## [1] 250000 250000 250000 250000 250000
## 
## $sufficient.adapt
## [1] FALSE FALSE FALSE FALSE FALSE
## 
## $n.iter
## [1] 20000
## 
## $n.burnin
## [1] 0
## 
## $n.thin
## [1] 100
## 
## $n.samples
## [1] 1000

Gjam

data<-sim_data$FacDenseSp20

fit_gjam(data,5000,500,"./gjam_models/gjam20fd.rda",interact=fac_inter[[6]])
## 
## Observations and responses:
## [1] 500  20
## ===========================================================================
## expanding covariance chains
## ===========================================================================
## Sensitivity by predictor variables f:
##      Estimate   SE CI_025 CI_975
## env       257 47.5  168.0    360
## env2      139 25.5   96.1    195
## 
## Coefficient matrix B:
##             sp01    sp02   sp03    sp04    sp05   sp06    sp07   sp08
## intercept -0.627 -0.7840 -0.782  0.3420 -0.0863  0.571  0.0562  0.308
## env       -1.960 -1.7000 -1.960 -2.3400 -1.3300 -2.370 -0.9180 -0.736
## env2       0.347 -0.0633 -0.457 -0.0897 -0.4940 -0.705 -0.6180 -0.926
## RMSPE      0.320  0.3650  0.372  0.3070  0.4090  0.279  0.4540  0.441
##             sp09   sp10    sp11   sp12   sp13   sp14   sp15    sp16   sp17
## intercept  0.607  0.589  0.2400  0.301  0.554  0.173 -0.119  0.0146 0.1620
## env       -0.747 -0.398  0.0591  0.458  0.974  1.150  1.590  2.0000 2.0000
## env2      -1.000 -1.040 -0.8710 -0.891 -0.920 -0.968 -1.090 -0.4860 0.0644
## RMSPE      0.397  0.421  0.4730  0.455  0.393  0.403  0.371  0.3310 0.3310
##            sp18   sp19   sp20
## intercept 0.349 -0.333 -0.606
## env       2.670  3.300  2.070
## env2      0.470  0.323  0.173
## RMSPE     0.291  0.272  0.319
## 
## Coefficient matrix B:
##                Estimate     SE  CI_025  CI_975 sig95
## sp01_intercept  -0.6270 0.0813 -0.8090 -0.4850     *
## sp01_env        -1.9600 0.1460 -2.2300 -1.6900     *
## sp01_env2        0.3470 0.0850  0.1690  0.5020     *
## sp02_intercept  -0.7840 0.0631 -0.9040 -0.6620     *
## sp02_env        -1.7000 0.1090 -1.9500 -1.5100     *
## sp02_env2       -0.0633 0.0932 -0.2190  0.1080      
## sp03_intercept  -0.7820 0.0846 -0.9390 -0.6110     *
## sp03_env        -1.9600 0.1100 -2.1800 -1.7500     *
## sp03_env2       -0.4570 0.0791 -0.6170 -0.3030     *
## sp04_intercept   0.3420 0.0682  0.1920  0.4640     *
## sp04_env        -2.3400 0.1110 -2.5600 -2.1300     *
## sp04_env2       -0.0897 0.0584 -0.2060  0.0164      
## sp05_intercept  -0.0863 0.0565 -0.1960  0.0218      
## sp05_env        -1.3300 0.1210 -1.5800 -1.1300     *
## sp05_env2       -0.4940 0.0599 -0.6080 -0.3720     *
## sp06_intercept   0.5710 0.1040  0.3530  0.7310     *
## sp06_env        -2.3700 0.1260 -2.6200 -2.1300     *
## sp06_env2       -0.7050 0.0662 -0.8320 -0.5770     *
## sp07_intercept   0.0562 0.0508 -0.0464  0.1520      
## sp07_env        -0.9180 0.0628 -1.0400 -0.7970     *
## sp07_env2       -0.6180 0.0604 -0.7340 -0.4970     *
## sp08_intercept   0.3080 0.0531  0.2030  0.4100     *
## sp08_env        -0.7360 0.0594 -0.8520 -0.6210     *
## sp08_env2       -0.9260 0.0722 -1.0600 -0.7860     *
## sp09_intercept   0.6070 0.0727  0.4740  0.7520     *
## sp09_env        -0.7470 0.0690 -0.8800 -0.6130     *
## sp09_env2       -1.0000 0.0719 -1.1500 -0.8690     *
## sp10_intercept   0.5890 0.0623  0.4700  0.7140     *
## sp10_env        -0.3980 0.0687 -0.5250 -0.2570     *
## sp10_env2       -1.0400 0.0706 -1.1800 -0.8970     *
## sp11_intercept   0.2400 0.0655  0.1200  0.3700     *
## sp11_env         0.0591 0.0559 -0.0526  0.1640      
## sp11_env2       -0.8710 0.0697 -1.0100 -0.7420     *
## sp12_intercept   0.3010 0.0610  0.1800  0.4170     *
## sp12_env         0.4580 0.0569  0.3480  0.5670     *
## sp12_env2       -0.8910 0.0612 -1.0100 -0.7740     *
## sp13_intercept   0.5540 0.0558  0.4470  0.6640     *
## sp13_env         0.9740 0.0637  0.8430  1.1000     *
## sp13_env2       -0.9200 0.0686 -1.0600 -0.7860     *
## sp14_intercept   0.1730 0.0695  0.0500  0.3110     *
## sp14_env         1.1500 0.0620  1.0200  1.2700     *
## sp14_env2       -0.9680 0.0743 -1.1100 -0.8190     *
## sp15_intercept  -0.1190 0.0486 -0.2130 -0.0248     *
## sp15_env         1.5900 0.0940  1.4200  1.7800     *
## sp15_env2       -1.0900 0.0932 -1.2700 -0.9210     *
## sp16_intercept   0.0146 0.0713 -0.1210  0.1470      
## sp16_env         2.0000 0.0946  1.8100  2.1800     *
## sp16_env2       -0.4860 0.0622 -0.6020 -0.3550     *
## sp17_intercept   0.1620 0.0643  0.0376  0.2850     *
## sp17_env         2.0000 0.0887  1.8300  2.1800     *
## sp17_env2        0.0644 0.0721 -0.0886  0.1920      
## sp18_intercept   0.3490 0.0557  0.2430  0.4600     *
## sp18_env         2.6700 0.1210  2.4400  2.9100     *
## sp18_env2        0.4700 0.0606  0.3460  0.5830     *
## sp19_intercept  -0.3330 0.0688 -0.4680 -0.2050     *
## sp19_env         3.3000 0.1670  2.9600  3.6200     *
## sp19_env2        0.3230 0.0570  0.2090  0.4340     *
## sp20_intercept  -0.6060 0.0716 -0.7450 -0.4740     *
## sp20_env         2.0700 0.1100  1.8700  2.3000     *
## sp20_env2        0.1730 0.0501  0.0734  0.2710     *
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
## Coefficient matrix B, standardized for X:
## NULL
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
## Coefficient matrix B, standardized for X and W:
## NULL
## 
## Last column indicates if 95% posterior distribution contains zero.
## 
##  Design Table
##      env env2
## VIF    1    1
## env2   0   NA
## 
##  Sample contains n = 500 observations on S = 20 response variables, and 2 predictors.  Data types (typeNames) include PA. There are 0 missing values in X and 0 missing values in Y. The RMSPE is 0.375, and the DIC is 384544.  Computation involved 5000 Gibbs steps, with a burnin of 500.

#load_gjam(data,name="./gjam_models/gjam20fd.rda", interact=fac_inter[[6]])
#gjfd5<-load_object("./gjam_models/gjam20fd.rda")

#to check posterior density of s in Sigma 
#gjfd5<-load_object("./gjam_models/gjam20fd.rda")
#plot(density(gjfd5$chains$sgibbs[,4]))

HMSC

data<-sim_data$FacDenseSp20
hm_mod<-fit_hmsc(data,"F_t",name="./HMmodels/hm20fd.rda" )
## [1] "Computing chain 1"
## [1] "Computing chain 2"
hm_conv(hm_mod)

hm_inter(hm_mod, interact = fac_inter[[6]])

Environmental filtering + Facilitation sparse 5 species

JSDM

## Summary for model '/tmp/RtmpKix4lZ/file40e917d13dae'
## Saved parameters: B Rho EnvRho 
## MCMC ran in parallel for 29.05 minutes at time 2019-04-13 17:22:13.
## 
## For each of 5 chains:
## Adaptation:            250000 iterations (possibly insufficient)
## Burn-in:               0 iterations
## Thin rate:             100 iterations
## Total chain length:    270000 iterations
## Posterior sample size: 200 draws
## 
## **WARNING** Rhat values indicate convergence failure.
## $B
##          [,1]     [,2]     [,3]
## [1,] 1.255418 1.081860 1.241431
## [2,] 1.025291 1.006684 1.026204
## [3,] 1.000823 1.001345 1.004635
## [4,] 1.211812 1.156605 1.209113
## [5,] 1.372985 1.050443 1.354270
## 
## $Rho
##           [,1]      [,2]      [,3]      [,4]     [,5]
## [1,] 0.9977941 1.0261430 1.0323888 1.0242354 1.001623
## [2,] 1.0261430 0.9978558 1.0094400 1.0882210 1.025190
## [3,] 1.0323888 1.0094400 0.9987781 1.0129030 1.160663
## [4,] 1.0242354 1.0882210 1.0129030 0.9978102 1.031993
## [5,] 1.0016226 1.0251898 1.1606628 1.0319930       NA
## 
## $EnvRho
##           [,1]      [,2]     [,3]      [,4]     [,5]
## [1,] 0.9979837 1.2006222 1.213731 1.2027486 1.404787
## [2,] 1.2006222 0.9982306 1.012141 1.2146691 1.238446
## [3,] 1.2137308 1.0121414 0.998331 1.1936308 1.259078
## [4,] 1.2027486 1.2146691 1.193631 0.9990681 1.115127
## [5,] 1.4047869 1.2384459 1.259078 1.1151275 0.997639
## $B
##      [,1] [,2] [,3]
## [1,]   17   44   17
## [2,]  169  469  127
## [3,] 1000 1000  500
## [4,]   20   25   20
## [5,]   13   66   14
## 
## $Rho
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    1  111   92  123  819
## [2,]  111    1  283   40  143
## [3,]   92  283    1  205   28
## [4,]  123   40  205    1  102
## [5,]  819  143   28  102    1
## 
## $EnvRho
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    1   20   19   29   13
## [2,]   20    1  252   20   18
## [3,]   19  252    1   21   17
## [4,]   29   20   21    1   32
## [5,]   13   18   17   32    1
## $n.chains
## [1] 5
## 
## $n.adapt
## [1] 250000 250000 250000 250000 250000
## 
## $sufficient.adapt
## [1] FALSE FALSE FALSE FALSE FALSE
## 
## $n.iter
## [1] 20000
## 
## $n.burnin
## [1] 0
## 
## $n.thin
## [1] 100
## 
## $n.samples
## [1] 1000

Environmental filtering + Facilitation sparse 10 species

JSDM

## Summary for model '/tmp/RtmpKix4lZ/file40e9113ddc9'
## Saved parameters: B Rho EnvRho 
## MCMC ran in parallel for 686.687 minutes at time 2019-04-13 17:51:16.
## 
## For each of 5 chains:
## Adaptation:            250000 iterations (possibly insufficient)
## Burn-in:               0 iterations
## Thin rate:             100 iterations
## Total chain length:    270000 iterations
## Posterior sample size: 200 draws
## 
## **WARNING** Rhat values indicate convergence failure.
## $B
##           [,1]     [,2]     [,3]
##  [1,] 1.079127 1.082576 1.069292
##  [2,] 1.493281 1.265593 1.547860
##  [3,] 1.228773 1.203569 1.171271
##  [4,] 1.001348 1.005780 1.010461
##  [5,] 1.000726 1.003454 1.007422
##  [6,] 1.009741 1.009018 1.010434
##  [7,] 1.001193 1.003615 1.000846
##  [8,] 1.055412 1.019015 1.064282
##  [9,] 1.007253 1.009355 1.008943
## [10,] 1.082071 1.013491 1.083509
## 
## $Rho
##            [,1]      [,2]      [,3]      [,4]      [,5]      [,6]
##  [1,] 0.9977516 1.0259531 1.0340329 1.0068896 1.0082188 1.0100219
##  [2,] 1.0259531 0.9994816 1.0084724 1.0240600 1.0077530 1.0250177
##  [3,] 1.0340329 1.0084724 0.9990054 1.0388638 1.0084130 1.0047410
##  [4,] 1.0068896 1.0240600 1.0388638 0.9998256 1.0171348 1.0086691
##  [5,] 1.0082188 1.0077530 1.0084130 1.0171348 0.9980083 1.0112323
##  [6,] 1.0100219 1.0250177 1.0047410 1.0086691 1.0112323 0.9977598
##  [7,] 1.0260664 1.0404806 1.0055234 1.0140496 1.0296225 1.0047627
##  [8,] 1.0210249 1.0100324 1.0119074 1.0123030 1.0101896 1.0161500
##  [9,] 1.0106588 1.0210052 1.0171462 1.0057247 1.0147989 1.0055479
## [10,] 1.0100571 1.0211629 1.0336511 1.0046977 1.0284525 1.0411663
##            [,7]      [,8]      [,9]    [,10]
##  [1,] 1.0260664 1.0210249 1.0106588 1.010057
##  [2,] 1.0404806 1.0100324 1.0210052 1.021163
##  [3,] 1.0055234 1.0119074 1.0171462 1.033651
##  [4,] 1.0140496 1.0123030 1.0057247 1.004698
##  [5,] 1.0296225 1.0101896 1.0147989 1.028453
##  [6,] 1.0047627 1.0161500 1.0055479 1.041166
##  [7,] 0.9992092 1.0156770 1.0207471 1.065461
##  [8,] 1.0156770 0.9976269 1.0032951 1.018329
##  [9,] 1.0207471 1.0032951 0.9978253 1.014369
## [10,] 1.0654609 1.0183288 1.0143692       NA
## 
## $EnvRho
##            [,1]      [,2]      [,3]      [,4]      [,5]      [,6]
##  [1,] 0.9979914 1.2997558 1.1178625 1.0205384 1.0294759 1.0230069
##  [2,] 1.2997558 0.9979005 1.1183563 1.3605378 1.3368724 1.3126681
##  [3,] 1.1178625 1.1183563 0.9988495 1.1493055 1.1571554 1.1309736
##  [4,] 1.0205384 1.3605378 1.1493055 0.9976748 1.0048199 1.0069981
##  [5,] 1.0294759 1.3368724 1.1571554 1.0048199 0.9982209 1.0053027
##  [6,] 1.0230069 1.3126681 1.1309736 1.0069981 1.0053027 0.9986515
##  [7,] 1.0220474 1.4070747 1.1580578 1.0015551 1.0074252 1.0026820
##  [8,] 1.0676153 1.2142164 1.1910105 1.0581631 1.0540330 1.0500890
##  [9,] 1.0263475 1.4745656 1.1763028 1.0010915 1.0041818 1.0062623
## [10,] 1.1216597 1.3088215 1.0688491 1.0791185 1.0488323 1.0733602
##            [,7]      [,8]      [,9]     [,10]
##  [1,] 1.0220474 1.0676153 1.0263475 1.1216597
##  [2,] 1.4070747 1.2142164 1.4745656 1.3088215
##  [3,] 1.1580578 1.1910105 1.1763028 1.0688491
##  [4,] 1.0015551 1.0581631 1.0010915 1.0791185
##  [5,] 1.0074252 1.0540330 1.0041818 1.0488323
##  [6,] 1.0026820 1.0500890 1.0062623 1.0733602
##  [7,] 0.9979547 1.0471104 1.0055009 1.0790593
##  [8,] 1.0471104 0.9991044 1.0409568 1.2608559
##  [9,] 1.0055009 1.0409568 0.9983401 1.0519840
## [10,] 1.0790593 1.2608559 1.0519840 0.9976922
## $B
##       [,1] [,2] [,3]
##  [1,]   52   49   55
##  [2,]   11   17   10
##  [3,]   19   20   24
##  [4,] 1000  374  266
##  [5,] 1000  567  333
##  [6,]  262  286  296
##  [7,]  839  602 1000
##  [8,]  129  212   94
##  [9,]  462  346  407
## [10,]   49  251   47
## 
## $Rho
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
##  [1,]    1  122   94  384  296  316  114  140  292   337
##  [2,]  122    1  558  143  481  155   81  262  144   148
##  [3,]   94  558    1   89  355  800 1000  317  214   104
##  [4,]  384  143   89    1  172  290  191  213  543   438
##  [5,]  296  481  355  172    1  273  110  421  192   116
##  [6,]  316  155  800  290  273    1  621  178  401   101
##  [7,]  114   81 1000  191  110  621    1  179  140    53
##  [8,]  140  262  317  213  421  178  179    1  630   181
##  [9,]  292  144  214  543  192  401  140  630    1   213
## [10,]  337  148  104  438  116  101   53  181  213     1
## 
## $EnvRho
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
##  [1,]    1   15   31  147  111  128  138   80  119    41
##  [2,]   15    1   37   13   14   15   12   22   11    15
##  [3,]   31   37    1   26   25   30   25   30   23    97
##  [4,]  147   13   26    1  449  363 1000   78 1000    48
##  [5,]  111   14   25  449    1  615  361   97  630    70
##  [6,]  128   15   30  363  615    1  696  109  358    50
##  [7,]  138   12   25 1000  361  696    1  110  488    48
##  [8,]   80   22   30   78   97  109  110    1  153    34
##  [9,]  119   11   23 1000  630  358  488  153    1    68
## [10,]   41   15   97   48   70   50   48   34   68     1
## $n.chains
## [1] 5
## 
## $n.adapt
## [1] 250000 250000 250000 250000 250000
## 
## $sufficient.adapt
## [1] FALSE FALSE FALSE FALSE FALSE
## 
## $n.iter
## [1] 20000
## 
## $n.burnin
## [1] 0
## 
## $n.thin
## [1] 100
## 
## $n.samples
## [1] 1000

Environmental filtering + Facilitation sparse 20 species

JSDM

## Summary for model '/tmp/RtmpKix4lZ/file40e9629c97ad'
## Saved parameters: B Rho EnvRho 
## MCMC ran in parallel for 2056.316 minutes at time 2019-04-14 05:17:59.
## 
## For each of 5 chains:
## Adaptation:            250000 iterations (possibly insufficient)
## Burn-in:               0 iterations
## Thin rate:             100 iterations
## Total chain length:    270000 iterations
## Posterior sample size: 200 draws
## 
## **WARNING** Rhat values indicate convergence failure.
## $B
##            [,1]     [,2]     [,3]
##  [1,] 1.2009264 1.211506 1.140623
##  [2,] 1.1860972 1.057014 1.212488
##  [3,] 1.1480327 1.027888 1.130378
##  [4,] 1.1752904 1.012028 1.161894
##  [5,] 1.0163618 1.173905 1.017844
##  [6,] 1.0115329 1.006395 1.026605
##  [7,] 1.0091098 1.000568 1.015941
##  [8,] 1.0159189 1.028463 1.011465
##  [9,] 1.0147953 1.019570 1.045332
## [10,] 1.0063291 1.008805 1.009135
## [11,] 1.0231183 1.005532 1.000423
## [12,] 0.9998188 1.002953 1.004414
## [13,] 1.0040687 1.002061 1.010954
## [14,] 1.0162013 1.004407 1.000635
## [15,] 1.0217897 1.066128 1.016222
## [16,] 1.0779196 1.021127 1.124577
## [17,] 1.5653333 1.128604 1.386253
## [18,] 1.1802226 1.141001 1.278626
## [19,] 1.4282395 1.039705 1.381102
## [20,] 1.1821177 1.113667 1.153018
## 
## $Rho
##           [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]
##  [1,] 1.000847 1.0105264 1.0594320 1.0311957 1.2633206 1.0801668 1.1559702
##  [2,] 1.010526 0.9988471 1.0347164 1.0179127 1.0613880 1.0230163 1.0307447
##  [3,] 1.059432 1.0347164 0.9983805 1.0179483 1.0331487 1.0054826 1.0215763
##  [4,] 1.031196 1.0179127 1.0179483 0.9985754 1.0399207 1.0145365 1.0319669
##  [5,] 1.263321 1.0613880 1.0331487 1.0399207 0.9999092 1.0185258 1.0313099
##  [6,] 1.080167 1.0230163 1.0054826 1.0145365 1.0185258 0.9988391 1.0187075
##  [7,] 1.155970 1.0307447 1.0215763 1.0319669 1.0313099 1.0187075 0.9984636
##  [8,] 1.076681 1.0181661 1.0230673 1.0621744 1.0090017 1.0207887 1.0098598
##  [9,] 1.042442 1.0404052 1.0318302 1.0238873 1.0086089 1.0203758 1.0175148
## [10,] 1.112164 1.0436578 1.0102728 1.0854974 1.2184900 1.0087108 1.0261739
## [11,] 1.010825 1.0439089 1.0278774 1.0531873 1.0647847 1.0246256 1.0084867
## [12,] 1.038213 1.0241498 1.1323483 1.0561975 1.2347239 1.0971471 1.0694127
## [13,] 1.054364 1.0385368 1.1159021 1.0814599 1.0384621 1.0391679 1.0316509
## [14,] 1.020562 1.0968086 1.0532577 1.0065540 1.0727440 1.0227308 1.0382510
## [15,] 1.076461 1.0397974 1.0543872 1.0127451 1.0357231 1.0936140 1.1598696
## [16,] 1.037002 1.0267529 1.0978669 1.1654193 1.0827285 1.0418937 1.0360895
## [17,] 1.031443 1.1373285 1.0616896 1.0254841 1.0218575 1.0344634 1.0407456
## [18,] 1.031825 1.0989802 1.0318980 1.0348120 1.0294232 1.0456659 1.0569231
## [19,] 1.072367 1.0229445 1.0265228 1.0050966 1.0670184 1.0136386 1.0543381
## [20,] 1.072482 1.0522922 1.0075304 1.0197436 1.0602047 1.0477436 1.0421095
##            [,8]      [,9]    [,10]    [,11]    [,12]     [,13]     [,14]
##  [1,] 1.0766813 1.0424415 1.112164 1.010825 1.038213 1.0543645 1.0205621
##  [2,] 1.0181661 1.0404052 1.043658 1.043909 1.024150 1.0385368 1.0968086
##  [3,] 1.0230673 1.0318302 1.010273 1.027877 1.132348 1.1159021 1.0532577
##  [4,] 1.0621744 1.0238873 1.085497 1.053187 1.056198 1.0814599 1.0065540
##  [5,] 1.0090017 1.0086089 1.218490 1.064785 1.234724 1.0384621 1.0727440
##  [6,] 1.0207887 1.0203758 1.008711 1.024626 1.097147 1.0391679 1.0227308
##  [7,] 1.0098598 1.0175148 1.026174 1.008487 1.069413 1.0316509 1.0382510
##  [8,] 0.9988498 1.0316442 1.004442 1.031162 1.009393 1.0138890 1.0018197
##  [9,] 1.0316442 0.9990939 1.029507 1.058210 1.016909 1.0157517 1.0348540
## [10,] 1.0044421 1.0295070 0.999536 1.011465 1.015406 1.0311761 1.0077301
## [11,] 1.0311618 1.0582103 1.011465 0.998224 1.024463 1.0098519 1.0388046
## [12,] 1.0093932 1.0169085 1.015406 1.024463 0.998927 1.0338068 1.0320701
## [13,] 1.0138890 1.0157517 1.031176 1.009852 1.033807 0.9989222 1.0141961
## [14,] 1.0018197 1.0348540 1.007730 1.038805 1.032070 1.0141961 0.9983649
## [15,] 1.0413908 1.0884157 1.027014 1.033635 1.033843 1.0213032 1.0494409
## [16,] 1.0330935 1.0140044 1.104972 1.059808 1.009797 1.0525673 1.0074466
## [17,] 1.0964333 1.0439595 1.142587 1.153220 1.038827 1.0320922 1.0484593
## [18,] 1.0456087 1.0327120 1.028069 1.077132 1.072817 1.1519735 1.0625570
## [19,] 1.0475133 1.0818652 1.171299 1.030860 1.047409 1.0604431 1.0792875
## [20,] 1.0379662 1.0501091 1.032796 1.038673 1.099362 1.1165480 1.0658583
##           [,15]     [,16]     [,17]    [,18]     [,19]    [,20]
##  [1,] 1.0764605 1.0370021 1.0314430 1.031825 1.0723675 1.072482
##  [2,] 1.0397974 1.0267529 1.1373285 1.098980 1.0229445 1.052292
##  [3,] 1.0543872 1.0978669 1.0616896 1.031898 1.0265228 1.007530
##  [4,] 1.0127451 1.1654193 1.0254841 1.034812 1.0050966 1.019744
##  [5,] 1.0357231 1.0827285 1.0218575 1.029423 1.0670184 1.060205
##  [6,] 1.0936140 1.0418937 1.0344634 1.045666 1.0136386 1.047744
##  [7,] 1.1598696 1.0360895 1.0407456 1.056923 1.0543381 1.042109
##  [8,] 1.0413908 1.0330935 1.0964333 1.045609 1.0475133 1.037966
##  [9,] 1.0884157 1.0140044 1.0439595 1.032712 1.0818652 1.050109
## [10,] 1.0270136 1.1049723 1.1425866 1.028069 1.1712995 1.032796
## [11,] 1.0336352 1.0598081 1.1532204 1.077132 1.0308596 1.038673
## [12,] 1.0338434 1.0097969 1.0388266 1.072817 1.0474094 1.099362
## [13,] 1.0213032 1.0525673 1.0320922 1.151974 1.0604431 1.116548
## [14,] 1.0494409 1.0074466 1.0484593 1.062557 1.0792875 1.065858
## [15,] 0.9989504 1.0339380 1.2269191 1.116314 1.1052650 1.109995
## [16,] 1.0339380 0.9980953 1.0156441 1.043229 1.0690521 1.068780
## [17,] 1.2269191 1.0156441 0.9978179 1.072580 1.0232699 1.064961
## [18,] 1.1163142 1.0432294 1.0725799 0.998882 1.0296178 1.095946
## [19,] 1.1052650 1.0690521 1.0232699 1.029618 0.9977304 1.092812
## [20,] 1.1099951 1.0687799 1.0649606 1.095946 1.0928117       NA
## 
## $EnvRho
##            [,1]      [,2]      [,3]      [,4]      [,5]      [,6]
##  [1,] 0.9983208 1.1114115 1.1679172 1.0515507 1.0974800 1.0708739
##  [2,] 1.1114115 0.9985632 1.4330087 1.0378733 1.0583634 1.1518020
##  [3,] 1.1679172 1.4330087 0.9975953 1.1585311 1.0618361 1.1149355
##  [4,] 1.0515507 1.0378733 1.1585311 0.9981781 1.1935854 1.1235101
##  [5,] 1.0974800 1.0583634 1.0618361 1.1935854 0.9982519 1.0301517
##  [6,] 1.0708739 1.1518020 1.1149355 1.1235101 1.0301517 0.9983819
##  [7,] 1.0811596 1.1013683 1.0838191 1.1468577 1.0056122 1.0194223
##  [8,] 1.0643056 1.1601580 1.0513585 1.1186866 1.0239043 1.0113177
##  [9,] 1.0986903 1.0983748 1.0977595 1.0954870 1.0056014 1.0164706
## [10,] 1.0685932 1.1036703 1.0652616 1.0655594 1.0131230 1.0080944
## [11,] 1.0389123 1.1273288 1.0396033 1.0874433 1.0254535 1.0112932
## [12,] 1.0533881 1.1282860 1.0641673 1.1153439 1.0229268 1.0089121
## [13,] 1.0854536 1.1221487 1.0752885 1.1072643 1.0220330 1.0183393
## [14,] 1.1121280 1.1253368 1.0734058 1.0833298 1.0194521 1.0177274
## [15,] 1.0790939 1.1209684 1.0779105 1.0973737 1.0365185 1.0119729
## [16,] 1.0614415 1.1806510 1.1004684 1.0631345 1.1458057 1.0821867
## [17,] 1.4058211 1.1052104 1.1712403 1.1719607 1.3054890 1.3240737
## [18,] 1.0696469 1.0675516 1.2424160 1.1309874 1.1608835 1.1159120
## [19,] 1.0751028 1.0420922 1.1383888 1.2513987 1.1738506 1.2700811
## [20,] 1.0951959 1.0278274 1.0410879 1.1706870 1.0682831 1.0891719
##            [,7]     [,8]      [,9]     [,10]     [,11]     [,12]     [,13]
##  [1,] 1.0811596 1.064306 1.0986903 1.0685932 1.0389123 1.0533881 1.0854536
##  [2,] 1.1013683 1.160158 1.0983748 1.1036703 1.1273288 1.1282860 1.1221487
##  [3,] 1.0838191 1.051358 1.0977595 1.0652616 1.0396033 1.0641673 1.0752885
##  [4,] 1.1468577 1.118687 1.0954870 1.0655594 1.0874433 1.1153439 1.1072643
##  [5,] 1.0056122 1.023904 1.0056014 1.0131230 1.0254535 1.0229268 1.0220330
##  [6,] 1.0194223 1.011318 1.0164706 1.0080944 1.0112932 1.0089121 1.0183393
##  [7,] 0.9991056 1.016641 1.0071037 1.0080521 1.0165293 1.0115380 1.0094274
##  [8,] 1.0166408 0.998281 1.0212560 1.0095855 1.0003797 1.0020574 1.0091582
##  [9,] 1.0071037 1.021256 0.9986401 1.0018860 1.0180396 1.0144343 1.0121478
## [10,] 1.0080521 1.009585 1.0018860 0.9995272 1.0113605 1.0111058 1.0018809
## [11,] 1.0165293 1.000380 1.0180396 1.0113605 0.9980360 0.9984231 1.0068005
## [12,] 1.0115380 1.002057 1.0144343 1.0111058 0.9984231 0.9985812 1.0101541
## [13,] 1.0094274 1.009158 1.0121478 1.0018809 1.0068005 1.0101541 0.9980014
## [14,] 1.0131252 1.008168 1.0053540 1.0008028 1.0100828 1.0127511 1.0036052
## [15,] 1.0259815 1.009301 1.0227359 1.0105417 1.0015252 1.0030144 1.0091385
## [16,] 1.0910810 1.065146 1.0741038 1.0409416 1.0433115 1.0563553 1.0607146
## [17,] 1.3447248 1.217563 1.2950608 1.2543017 1.1489788 1.1797843 1.3066543
## [18,] 1.1898546 1.107894 1.1796378 1.1251056 1.0655662 1.0980767 1.1718814
## [19,] 1.2282162 1.218350 1.1688814 1.1834992 1.1919342 1.2401654 1.2418950
## [20,] 1.0967294 1.120749 1.0597162 1.0601469 1.1040554 1.1067132 1.0897829
##           [,14]    [,15]     [,16]     [,17]    [,18]    [,19]    [,20]
##  [1,] 1.1121280 1.079094 1.0614415 1.4058211 1.069647 1.075103 1.095196
##  [2,] 1.1253368 1.120968 1.1806510 1.1052104 1.067552 1.042092 1.027827
##  [3,] 1.0734058 1.077910 1.1004684 1.1712403 1.242416 1.138389 1.041088
##  [4,] 1.0833298 1.097374 1.0631345 1.1719607 1.130987 1.251399 1.170687
##  [5,] 1.0194521 1.036519 1.1458057 1.3054890 1.160883 1.173851 1.068283
##  [6,] 1.0177274 1.011973 1.0821867 1.3240737 1.115912 1.270081 1.089172
##  [7,] 1.0131252 1.025981 1.0910810 1.3447248 1.189855 1.228216 1.096729
##  [8,] 1.0081681 1.009301 1.0651457 1.2175628 1.107894 1.218350 1.120749
##  [9,] 1.0053540 1.022736 1.0741038 1.2950608 1.179638 1.168881 1.059716
## [10,] 1.0008028 1.010542 1.0409416 1.2543017 1.125106 1.183499 1.060147
## [11,] 1.0100828 1.001525 1.0433115 1.1489788 1.065566 1.191934 1.104055
## [12,] 1.0127511 1.003014 1.0563553 1.1797843 1.098077 1.240165 1.106713
## [13,] 1.0036052 1.009138 1.0607146 1.3066543 1.171881 1.241895 1.089783
## [14,] 0.9984386 1.018893 1.0429691 1.2955036 1.165180 1.216233 1.089638
## [15,] 1.0188931 0.997824 1.0626465 1.2283584 1.101777 1.296548 1.100136
## [16,] 1.0429691 1.062647 0.9979461 1.4826346 1.073386 1.341845 1.121754
## [17,] 1.2955036 1.228358 1.4826346 0.9996401 1.113600 1.368712 1.385371
## [18,] 1.1651799 1.101777 1.0733860 1.1136004 0.998105 1.262442 1.162356
## [19,] 1.2162327 1.296548 1.3418450 1.3687115 1.262442 0.998575 1.299824
## [20,] 1.0896376 1.100136 1.1217538 1.3853705 1.162356 1.299824 0.998583
## $B
##       [,1] [,2] [,3]
##  [1,]   24   21   32
##  [2,]   22   59   19
##  [3,]   27  108   32
##  [4,]   22  251   24
##  [5,]  227   23  216
##  [6,]  273  395  140
##  [7,]  351 1000  250
##  [8,]  177  104  232
##  [9,]  206  144   69
## [10,]  384  290  280
## [11,]  128  404 1000
## [12,] 1000  570  505
## [13,]  887  747  270
## [14,]  170 1000 1000
## [15,]  175   51  217
## [16,]   43  147   29
## [17,]   10   29   13
## [18,]   22   26   16
## [19,]   12   84   13
## [20,]   23   33   25
## 
## $Rho
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
##  [1,]    1  422   57   96   17   43   24   74   81    32   502   101    59
##  [2,]  422    1   91  212   54  128  110  167   93    75    89   128    87
##  [3,]   57   91    1  172   94  434  162  154  111   298   118    29    33
##  [4,]   96  212  172    1   92  399  138   52  123    41    74    65    43
##  [5,]   17   54   94   92    1  164   95  612  312    19    71    18    95
##  [6,]   43  128  434  399  164    1  152  162  180   349   118    37    80
##  [7,]   24  110  162  138   95  152    1  379  185   129   435    48   101
##  [8,]   74  167  154   52  612  162  379    1  105   519   122   477   204
##  [9,]   81   93  111  123  312  180  185  105    1   112    61   263   190
## [10,]   32   75  298   41   19  349  129  519  112     1   247   184   102
## [11,]  502   89  118   74   71  118  435  122   61   247     1   120   301
## [12,]  101  128   29   65   18   37   48  477  263   184   120     1    92
## [13,]   59   87   33   43   95   80  101  204  190   102   301    92     1
## [14,]  150   38   72  603   57  373   83  739   91   354    80   100   193
## [15,]   45   80   61  273   90   38   24   82   39   153    99    95   137
## [16,]   92  111   36   23   43   83  107   95  198    34    55   302    66
## [17,]   97   28   53  253  137  244  115   38  170    26    25   104   118
## [18,]  107   38  109  107  103   72   57   73   98   121    44    47    27
## [19,]   46  150  110  517   52  216   66   81   42    23   137    80    54
## [20,]   51   66  339  154   64   75   85   98   68    98    82    40    31
##       [,14] [,15] [,16] [,17] [,18] [,19] [,20]
##  [1,]   150    45    92    97   107    46    51
##  [2,]    38    80   111    28    38   150    66
##  [3,]    72    61    36    53   109   110   339
##  [4,]   603   273    23   253   107   517   154
##  [5,]    57    90    43   137   103    52    64
##  [6,]   373    38    83   244    72   216    75
##  [7,]    83    24   107   115    57    66    85
##  [8,]   739    82    95    38    73    81    98
##  [9,]    91    39   198   170    98    42    68
## [10,]   354   153    34    26   121    23    98
## [11,]    80    99    55    25    44   137    82
## [12,]   100    95   302   104    47    80    40
## [13,]   193   137    66   118    27    54    31
## [14,]     1    69   337    73    53    44    61
## [15,]    69     1    88    19    33    36    34
## [16,]   337    88     1   210    83    48    51
## [17,]    73    19   210     1    51   125    51
## [18,]    53    33    83    51     1   123    37
## [19,]    44    36    48   125   123     1    37
## [20,]    61    34    51    51    37    37     1
## 
## $EnvRho
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
##  [1,]    1   42   28   93   37   48   50   58   36    53    87    66    47
##  [2,]   42    1   15  128   56   25   37   24   36    35    29    28    29
##  [3,]   28   15    1   29   57   32   42   62   37    51    84    56    50
##  [4,]   93  128   29    1   25   32   26   32   37    50    39    31    33
##  [5,]   37   56   57   25    1  137  521  146  787   251   123   139   141
##  [6,]   48   25   32   32  137    1  536  243  205   335   240   303   169
##  [7,]   50   37   42   26  521  536    1  189  402   349   214   254   319
##  [8,]   58   24   62   32  146  243  189    1  251   258  1000  1000   283
##  [9,]   36   36   37   37  787  205  402  251    1   705   162   189   266
## [10,]   53   35   51   50  251  335  349  258  705     1   244   246  1000
## [11,]   87   29   84   39  123  240  214 1000  162   244     1  1000   367
## [12,]   66   28   56   31  139  303  254 1000  189   246  1000     1   324
## [13,]   47   29   50   33  141  169  319  283  266  1000   367   324     1
## [14,]   36   28   50   43  160  187  217  312  412  1000   276   246   749
## [15,]   55   31   48   36   89  301  132  550  140   294  1000  1000   305
## [16,]   72   22   40   57   26   43   37   50   46    76    73    56    58
## [17,]   17   47   24   37   15   15   14   20   15    17    26    23    15
## [18,]   76   74   21   51   23   30   21   33   22    29    51    36    23
## [19,]  108  155   40   28   32   17   19   19   24    22    21    18    18
## [20,]   41  182  143   38   68   42   39   31   55    57    34    33    38
##       [,14] [,15] [,16] [,17] [,18] [,19] [,20]
##  [1,]    36    55    72    17    76   108    41
##  [2,]    28    31    22    47    74   155   182
##  [3,]    50    48    40    24    21    40   143
##  [4,]    43    36    57    37    51    28    38
##  [5,]   160    89    26    15    23    32    68
##  [6,]   187   301    43    15    30    17    42
##  [7,]   217   132    37    14    21    19    39
##  [8,]   312   550    50    20    33    19    31
##  [9,]   412   140    46    15    22    24    55
## [10,]  1000   294    76    17    29    22    57
## [11,]   276  1000    73    26    51    21    34
## [12,]   246  1000    56    23    36    18    33
## [13,]   749   305    58    15    23    18    38
## [14,]     1   255    75    16    24    19    39
## [15,]   255     1   125    19    38    15    36
## [16,]    75   125     1    13    48    14    30
## [17,]    16    19    13     1   103    14    14
## [18,]    24    38    48   103     1    18    25
## [19,]    19    15    14    14    18     1    21
## [20,]    39    36    30    14    25    21     1
## $n.chains
## [1] 5
## 
## $n.adapt
## [1] 250000 250000 250000 250000 250000
## 
## $sufficient.adapt
## [1] FALSE FALSE FALSE FALSE FALSE
## 
## $n.iter
## [1] 20000
## 
## $n.burnin
## [1] 0
## 
## $n.thin
## [1] 100
## 
## $n.samples
## [1] 1000

Environmental filtering + Competition dense 5 species

JSDM

## Summary for model '/tmp/RtmpKix4lZ/file40e9127bbb96'
## Saved parameters: B Rho EnvRho 
## MCMC ran in parallel for 29.308 minutes at time 2019-04-15 15:34:20.
## 
## For each of 5 chains:
## Adaptation:            250000 iterations (possibly insufficient)
## Burn-in:               0 iterations
## Thin rate:             100 iterations
## Total chain length:    270000 iterations
## Posterior sample size: 200 draws
## 
## Successful convergence based on Rhat values (all < 1.1).
## $B
##           [,1]      [,2]      [,3]
## [1,] 0.9992699 1.0039019 1.0085401
## [2,] 1.0128736 1.0070599 1.0090347
## [3,] 1.0084590 0.9998466 1.0094351
## [4,] 0.9994956 0.9994269 0.9994353
## [5,] 0.9990868 1.0059362 1.0323796
## 
## $Rho
##           [,1]      [,2]      [,3]      [,4]     [,5]
## [1,] 0.9997647 1.0111732 1.0136253 1.0262793 1.057643
## [2,] 1.0111732 0.9986603 1.0244584 1.0067418 1.067133
## [3,] 1.0136253 1.0244584 0.9983207 1.0027597 1.033900
## [4,] 1.0262793 1.0067418 1.0027597 0.9990709 1.018522
## [5,] 1.0576430 1.0671326 1.0339003 1.0185219       NA
## 
## $EnvRho
##           [,1]      [,2]      [,3]      [,4]      [,5]
## [1,] 0.9985283 1.0042437 1.0066617 1.0130860 1.0157941
## [2,] 1.0042437 0.9976154 1.0015341 1.0045804 1.0241824
## [3,] 1.0066617 1.0015341 0.9986805 0.9995707 1.0221389
## [4,] 1.0130860 1.0045804 0.9995707 0.9984863 1.0312755
## [5,] 1.0157941 1.0241824 1.0221389 1.0312755 0.9979406
## $B
##      [,1] [,2] [,3]
## [1,] 1000 1000  389
## [2,]  210  355  355
## [3,]  320 1000  272
## [4,] 1000 1000 1000
## [5,] 1000  463   95
## 
## $Rho
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    1  252  209  114   59
## [2,]  252    1  132  483   52
## [3,]  209  132    1  611   96
## [4,]  114  483  611    1  162
## [5,]   59   52   96  162    1
## 
## $EnvRho
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    1  556  455  431  207
## [2,]  556    1  795  661  120
## [3,]  455  795    1 1000  130
## [4,]  431  661 1000    1  100
## [5,]  207  120  130  100    1
## $n.chains
## [1] 5
## 
## $n.adapt
## [1] 250000 250000 250000 250000 250000
## 
## $sufficient.adapt
## [1] FALSE FALSE FALSE FALSE FALSE
## 
## $n.iter
## [1] 20000
## 
## $n.burnin
## [1] 0
## 
## $n.thin
## [1] 100
## 
## $n.samples
## [1] 1000

Environmental filtering + Competition dense 10 species

## Summary for model '/tmp/RtmpKix4lZ/file40e9559ce9d8'
## Saved parameters: B Rho EnvRho 
## MCMC ran in parallel for 695.614 minutes at time 2019-04-15 16:03:39.
## 
## For each of 5 chains:
## Adaptation:            250000 iterations (possibly insufficient)
## Burn-in:               0 iterations
## Thin rate:             100 iterations
## Total chain length:    270000 iterations
## Posterior sample size: 200 draws
## 
## **WARNING** Rhat values indicate convergence failure.
## $B
##           [,1]      [,2]     [,3]
##  [1,] 1.184491 1.0924718 1.174168
##  [2,] 1.002562 1.0199804 1.032937
##  [3,] 1.004197 1.0037121 1.003388
##  [4,] 1.003017 1.0063025 1.003671
##  [5,] 1.001863 1.0028406 1.003823
##  [6,] 1.003347 0.9994502 1.007329
##  [7,] 1.005931 1.0148814 1.008707
##  [8,] 1.133921 1.1394220 1.120682
##  [9,] 1.036365 1.0229201 1.042030
## [10,] 1.014222 1.0252783 1.032749
## 
## $Rho
##            [,1]      [,2]      [,3]      [,4]      [,5]     [,6]      [,7]
##  [1,] 0.9982981 1.0736358 1.0163397 1.0389520 1.0391268 1.028132 1.0342467
##  [2,] 1.0736358 0.9982061 1.0855782 1.0379838 1.0106180 1.090370 1.0482529
##  [3,] 1.0163397 1.0855782 0.9990348 1.0100777 1.0058427 1.009966 1.0187807
##  [4,] 1.0389520 1.0379838 1.0100777 0.9976574 1.0388340 1.024137 1.0056891
##  [5,] 1.0391268 1.0106180 1.0058427 1.0388340 0.9985805 1.004055 1.0260171
##  [6,] 1.0281324 1.0903700 1.0099655 1.0241372 1.0040550 0.997530 1.0135124
##  [7,] 1.0342467 1.0482529 1.0187807 1.0056891 1.0260171 1.013512 0.9977998
##  [8,] 1.0162888 1.0194622 1.0142569 1.0749787 1.0254736 1.020784 1.0640900
##  [9,] 1.0177287 1.0434650 1.0035099 1.0273927 1.0569636 1.012938 1.0127183
## [10,] 1.0241698 1.0189370 1.0141069 1.0063696 1.0130281 1.022538 1.0905019
##            [,8]      [,9]    [,10]
##  [1,] 1.0162888 1.0177287 1.024170
##  [2,] 1.0194622 1.0434650 1.018937
##  [3,] 1.0142569 1.0035099 1.014107
##  [4,] 1.0749787 1.0273927 1.006370
##  [5,] 1.0254736 1.0569636 1.013028
##  [6,] 1.0207836 1.0129383 1.022538
##  [7,] 1.0640900 1.0127183 1.090502
##  [8,] 0.9986921 1.0073322 1.020647
##  [9,] 1.0073322 0.9986258 1.017626
## [10,] 1.0206467 1.0176263       NA
## 
## $EnvRho
##            [,1]      [,2]     [,3]      [,4]      [,5]      [,6]      [,7]
##  [1,] 0.9980917 1.1132907 1.116068 1.0538487 1.0579563 1.1174585 1.1770617
##  [2,] 1.1132907 0.9993671 1.032695 1.0376641 1.0367794 1.0288659 1.0240739
##  [3,] 1.1160684 1.0326949 0.998218 1.0067471 1.0039030 1.0036538 1.0288561
##  [4,] 1.0538487 1.0376641 1.006747 0.9992088 0.9997989 1.0071268 1.0291796
##  [5,] 1.0579563 1.0367794 1.003903 0.9997989 0.9978700 1.0064940 1.0256165
##  [6,] 1.1174585 1.0288659 1.003654 1.0071268 1.0064940 0.9979281 1.0108040
##  [7,] 1.1770617 1.0240739 1.028856 1.0291796 1.0256165 1.0108040 0.9980596
##  [8,] 1.0269566 1.0168974 1.106804 1.0785522 1.0895479 1.0590564 1.0315088
##  [9,] 1.1552814 1.0340803 1.041486 1.0330602 1.0193857 1.0291867 1.0513752
## [10,] 1.0726914 1.0117231 1.036152 1.0362888 1.0314847 1.0196400 1.0156937
##            [,8]      [,9]     [,10]
##  [1,] 1.0269566 1.1552814 1.0726914
##  [2,] 1.0168974 1.0340803 1.0117231
##  [3,] 1.1068043 1.0414856 1.0361524
##  [4,] 1.0785522 1.0330602 1.0362888
##  [5,] 1.0895479 1.0193857 1.0314847
##  [6,] 1.0590564 1.0291867 1.0196400
##  [7,] 1.0315088 1.0513752 1.0156937
##  [8,] 0.9989128 1.0795098 1.0555299
##  [9,] 1.0795098 0.9981866 1.0369466
## [10,] 1.0555299 1.0369466 0.9987184
## $B
##       [,1] [,2] [,3]
##  [1,]   24   38   25
##  [2,]  802  157   93
##  [3,]  833  870 1000
##  [4,]  573  462  566
##  [5,]  994  601  648
##  [6,]  708 1000  329
##  [7,]  420  240  320
##  [8,]   29   28   33
##  [9,]  123  174  114
## [10,]  206  117  100
## 
## $Rho
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
##  [1,]    1   49  197   83   87  125   89  176  184   124
##  [2,]   49    1   40   82  315   39   73  187   71   174
##  [3,]  197   40    1  387  377  273  177  209  857   269
##  [4,]   83   82  387    1   81  136 1000   50  131   442
##  [5,]   87  315  377   81    1 1000  118  169   59   219
##  [6,]  125   39  273  136 1000    1 1000  144  242   144
##  [7,]   89   73  177 1000  118 1000    1   55  216    41
##  [8,]  176  187  209   50  169  144   55    1  381   155
##  [9,]  184   71  857  131   59  242  216  381    1   175
## [10,]  124  174  269  442  219  144   41  155  175     1
## 
## $EnvRho
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
##  [1,]    1   39   33   59   59   34   24  134   31    59
##  [2,]   39    1   96   83   84  108  170  178   92   306
##  [3,]   33   96    1  509  591  612  105   37  105    96
##  [4,]   59   83  509    1 1000  326  105   44  114    97
##  [5,]   59   84  591 1000    1  385  119   39  181    99
##  [6,]   34  108  612  326  385    1  256   59  112   172
##  [7,]   24  170  105  105  119  256    1  113   67   194
##  [8,]  134  178   37   44   39   59  113    1   69   222
##  [9,]   31   92  105  114  181  112   67   69    1   123
## [10,]   59  306   96   97   99  172  194  222  123     1
## $n.chains
## [1] 5
## 
## $n.adapt
## [1] 250000 250000 250000 250000 250000
## 
## $sufficient.adapt
## [1] FALSE FALSE FALSE FALSE FALSE
## 
## $n.iter
## [1] 20000
## 
## $n.burnin
## [1] 0
## 
## $n.thin
## [1] 100
## 
## $n.samples
## [1] 1000

Environmental filtering + Competition dense 20 species

Environmental filtering + Competition sparse 5 species

Environmental filtering + Competition dense 10 species

Environmental filtering + Competition dense 5 species

Visualization for true interactions